TechFundu

  • Increase font size
  • Default font size
  • Decrease font size
Welcome Guest,  Login | Join Now
Home Read Articles Java Technologies


How do you split a string in Java?

(3 votes, average 4.00 out of 5)
It is very easy to spilt a string in java. Before JDK1.4 code, there was StringTokenizer class for spliting a string using a delimiter, however this class has become legacy in JDK1.4 and upward. This is what JDK1.4 documentation says about this class.

"StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex...

Last Updated on Friday, 21 May 2010 05:37
 

SCJP Exam Prepration Questions - Part 5

Question 201Given:15. public class Yippee {16. public static void main(String [] args) {17. for(int x = 1; x < args.length; x++) {18. System.out.print(args[x] +“ “);19. }20. }21. }and two separate command line invocations:java Yippeejava Yippee 1234What is the result?A. No output is produced.123B. No output is produced.234C. No output is produced.1234D. An exception is thrown at runtime.123E. An exception is thrown at runtime.234F. An exception is thrown at rijntime.1234Answer: B
Question...

Last Updated on Tuesday, 19 January 2010 09:46
 

SCJP Exam Prepration Questions - Part 4

Question 151

Click the Exhibit button.

1. public class SimpleCalc {

2. public int value;

3. public void calculate() { value += 7; }

4. }

And:

1. public class MultiCalc extends SimpleCalc {

2. public void calculate() { value -= 3; }

3. public void calculate(int multiplier) {

4. calculate();

5. super.calculate();

6. value *=multiplier;

7. }

8. public static void main(String[] args) {

9. MultiCalc calculator = new MultiCalc();

10. calculator.calculate(2);

11...

Last Updated on Tuesday, 19 January 2010 18:39
 

SCJP Exam Prepration Questions - Part 3

Question 100

Assuming that the serializeBanana() and the deserializeBanana()

methods will correctly use Java serialization and given:

13. import java.io.*;

14. class Food implemertts Serializable {int good = 3;}

15. class Fruit externds Food {int juice = 5;}

16. public class Banana extends Fruit {

17. int yellow = 4;

18. public static void main(String [] args) {

19. Banana b = new Banana(); Banana b2 = new Banana();

20. b.serializeBanana(b); // assume correct serialization

21. b2 =...

Last Updated on Tuesday, 19 January 2010 09:38
 
  • «
  •  Start 
  •  Prev 
  •  1 
  •  2 
  •  3 
  •  4 
  •  5 
  •  Next 
  •  End 
  • »


Page 1 of 5

Follow us on Twitter