I was reading a program as follows
import java.util.StringTokenizer;
class Tokentester
{
public static void main(String[] arguments)
{
StringTokenizer st1,st2;
String quote1="Vdef 3 -1/16";
st1=new StringTokenizer(quote1);
System.out.println("Token 1: "+st1.nextToken());
System.out.println("Token 2: "+st1.nextToken());
System.out.println("Token 3: "+st1.nextToken());
String quote2="NGNDFBgh 27/32@3/ewtg@tryh@eretgse";
st2=new StringTokenizer(quote2,"@");
System.out.println("Token 1: "+st2.nextToken());
System.out.println("Token 2: "+st2.nextToken());
System.out.println("Token 3: "+st2.nextToken());
}
}
in c++ when we create object of a class we dont write new but in java when we have declared st1,st2 as instance of class stringtokenizer then why we are using new operator
in above program.i tghink StringTokenizer is a constructor which is being called in
st1=new StringTokenizer(quote1);