answersLogoWhite

0

As of Java 1.6 it has 3:

StringTokenizer(String str)

StringTokenizer(String str, String delim)

StringTokenizer(String str, String delim, boolean returnDelims)

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

What is stringtokenizor in java?

StringTokenizer is a class in Java that allows you to iterate through a String's tokens, or parts that resemble a defined pattern. By default, StringTokenizer uses "\t\n\r\f" (whitespace) to break up a String. You can override this in the constructor for your own pattern. These days, the split method of String is used instead of StringTokenizer. 2 examples below: StringTokenizer st = new StringTokenizer("Hello World"); System.out.println(st.countTokens()); //2 System.out.println(st.nextElement()); //Hello System.out.println(st.nextElement()); //World StringTokenizer st = new StringTokenizer("Hello,World","[aeiou]"); System.out.println(st.countTokens()); //4 while(st.hasMoreElements()) System.out.print(st.nextElement()); //Hll,Wrld


How many constructors does class Exception have?

The Exception class has 4 constructors. They are: a. Exception() b. Exception(String arg) c. Exception(String arg, Throwable arg1) d. Exception(Throwable arg)


How can you identify a constructor from among any other methods in a class?

Constructors have the same identifier as that of the class, so if the name of your class is Book then your constructor must also be named Book. Constructors have no return type, not even void.


How many constructors can c have?

A class can have any number of constructors, as far as they are having different parameters or different number of parameters. For example, a class A can have following constructors & even more: A() -the default constructor A(A objectA) -the copy constructor A(int p) A(int p1, int p2) A(int[] p1, float p2) A(double p1, double p2, int p3) A(A objA, int[] p) A(B objB)


What is the difference between default constructor and parameterized constructor?

A default constructor is one that has no parameters (C++ also calls constructors with all default parameters a default constructor), while a parameterized constructor is one that has at least one parameter without a default value. Default constructors can be provided by the compiler if no other constructors are defined for that class or any class the class inherits from, while parameterized constructors must always be defined by the developer.

Related Questions

For what purpose constructors are used in Java?

Constructors are used to create the instance of a class.


What is stringtokenizor in java?

StringTokenizer is a class in Java that allows you to iterate through a String's tokens, or parts that resemble a defined pattern. By default, StringTokenizer uses "\t\n\r\f" (whitespace) to break up a String. You can override this in the constructor for your own pattern. These days, the split method of String is used instead of StringTokenizer. 2 examples below: StringTokenizer st = new StringTokenizer("Hello World"); System.out.println(st.countTokens()); //2 System.out.println(st.nextElement()); //Hello System.out.println(st.nextElement()); //World StringTokenizer st = new StringTokenizer("Hello,World","[aeiou]"); System.out.println(st.countTokens()); //4 while(st.hasMoreElements()) System.out.print(st.nextElement()); //Hll,Wrld


How many constructors does class Exception have?

The Exception class has 4 constructors. They are: a. Exception() b. Exception(String arg) c. Exception(String arg, Throwable arg1) d. Exception(Throwable arg)


What is the order of constructors and destructors of object?

The order of constructors is determined by the sequence they are called in the code, starting with the base class constructor and moving to the derived class constructor. Destructors are called in the reverse order of constructors, starting with the derived class destructor and moving to the base class destructor.


How can you identify a constructor from among any other methods in a class?

Constructors have the same identifier as that of the class, so if the name of your class is Book then your constructor must also be named Book. Constructors have no return type, not even void.


How many constructors can c have?

A class can have any number of constructors, as far as they are having different parameters or different number of parameters. For example, a class A can have following constructors & even more: A() -the default constructor A(A objectA) -the copy constructor A(int p) A(int p1, int p2) A(int[] p1, float p2) A(double p1, double p2, int p3) A(A objA, int[] p) A(B objB)


Why you use constructors?

To create an instance of the class that implementing that constructor


What are different type of constructor in java?

Every class, including abstract classes, MUST have a constructor. The different types are: a. Regular constructors b. Overloaded constructors and c. Private constructors


What is main advantage of using constructors in java?

Constructors have the same name as the class itself and they do not specify a return type, not even void because they return the instance of the class itself. Because constructors have the same name as the class then they allow method overloading and also save memory and execution time of program. Program release memory of constructors function after using this function and it reduce program complexity.


What is the difference between default constructor and parameterized constructor?

A default constructor is one that has no parameters (C++ also calls constructors with all default parameters a default constructor), while a parameterized constructor is one that has at least one parameter without a default value. Default constructors can be provided by the compiler if no other constructors are defined for that class or any class the class inherits from, while parameterized constructors must always be defined by the developer.


How many constructors may be defined for a class?

As many as are required for the class to function. All classes other than static classes require at least one constructor. Most classes will also provide copy and move constructors (with corresponding copy and move assignment operators). Additional constructors are usually provided to increase the flexibility of the class, allowing users a variety of ways to initialise objects of the class. Constructors that accept just one argument (excluding the copy and move constructors) are regarded as being conversion constructors because, from a user's perspective, they effectively convert their argument into an object of the class. Although there is effectively no limit to the number of constructors you can define, do keep in mind the mantra that simple concepts should be expressed simply and no simpler. Make good and proper use of inline initialisation, default arguments and delegation. Use explicit constructors to avoid narrowing issues and implicit conversions where narrowing is acceptable. Also, make good use of RAII (resource acquisition is initialisation) to ensure proper cleanup should any member fail to initialise during construction. For efficiency, perform as much initialisation as possible outside the body of the constructor. Ideally, the constructor body should contain no code at all.


What is different between constructor and method?

Constructors have no return type and their names must exactly match the class name. Apart from this constructors and methods are similar to one another.