Results 1 to 2 of 2
Thread: How to get part of a String?
- 12-22-2007, 11:30 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 49
- Rep Power
- 0
How to get part of a String?
I have following code which produces the required output:
Output:Java Code:String fileNameWithExt = "interface_for_database_18sep07.txt"; String fileName = fileNameWithExt.substring(0, 30); System.out.println(fileName);
The point is, I have mentioned the ending index of the string in substring(…) method. How can I make it a bit flexible because the filename can change.Java Code:interface_for_database_18sep07
java.lang.StackOverflowError
I have written a recursive module and I get java.lang.StackOverflowError. I got some output before this exception. I want to know after how much iteration this exception is raised. Wont Java compiler identify this recursive statement at compile time?
- PEACE
- 12-23-2007, 06:58 AM #2
I want to know after how much iteration this exception is raised.Java Code:String fileNameWithExt = "interface_for_database_18sep07.txt"; int dot = fileNameWithExt.indexOf("."); String fileName = fileNameWithExt.substring(0, dot); System.out.println(fileName);
Depends on how you have set up your method. I would try to use some println statements to track what you think should be happening as it recurses.
Wont Java compiler identify this recursive statement at compile time?
Probably not; depends on what you wrote. Your code can compile okay and create all kinds of problems at runtime.
Similar Threads
-
Inventory part 2 help please
By badness in forum New To JavaReplies: 1Last Post: 12-12-2007, 07:51 AM -
Help with mathematical part in java
By lenny in forum Advanced JavaReplies: 3Last Post: 08-09-2007, 01:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks