Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > StringTokenizer undefined?

Reply
Thread Tools

StringTokenizer undefined?

 
 
Sean Washington
Guest
Posts: n/a
 
      09-10-2006
I could have swore I was doing everything right, but no matter what I
try I end up getting the following error:

Exception in thread "main" java.lang.Error: Unresolved compilation
problem:
The constructor StringTokenizer(String, String) is undefined

at StringTokenizer.main(StringTokenizer.java:

Here is my code:

import java.util.*;

public class StringTokenizer
{
public static void main(String[] Args)
{
String ssn = "123-34-7948";
StringTokenizer ssnToken = new StringTokenizer(ssn, "-");
}
}

What's am I doing wrong?

 
Reply With Quote
 
 
 
 
Mike Schilling
Guest
Posts: n/a
 
      09-10-2006
Sean Washington wrote:
> I could have swore I was doing everything right, but no matter what I
> try I end up getting the following error:
>
> Exception in thread "main" java.lang.Error: Unresolved compilation
> problem:
> The constructor StringTokenizer(String, String) is undefined
>
> at StringTokenizer.main(StringTokenizer.java:
>
> Here is my code:
>
> import java.util.*;
>
> public class StringTokenizer
> {
> public static void main(String[] Args)
> {
> String ssn = "123-34-7948";
> StringTokenizer ssnToken = new StringTokenizer(ssn, "-");
> }
> }
>
> What's am I doing wrong?


Not defining a constructor for StringTokenizer. Of, if you want to
construct a java.util.StringTokenizer, you need to say so, because you've
asked to construct an instance of *your* StringTokenizer class. You'd need
to say

java.util.StringTokenizer ssnToken = new java.util.StringTokenizer(ssn,
"-");


The simplest fix is to call your class something else.


 
Reply With Quote
 
 
 
 
hiwa
Guest
Posts: n/a
 
      09-10-2006
Sean Washington のメッセージ:

> I could have swore I was doing everything right, but no matter what I
> try I end up getting the following error:
>
> Exception in thread "main" java.lang.Error: Unresolved compilation
> problem:
> The constructor StringTokenizer(String, String) is undefined
>
> at StringTokenizer.main(StringTokenizer.java:
>
> Here is my code:
>
> import java.util.*;
>
> public class StringTokenizer
> {
> public static void main(String[] Args)
> {
> String ssn = "123-34-7948";
> StringTokenizer ssnToken = new StringTokenizer(ssn, "-");
> }
> }
>
> What's am I doing wrong?

Your class name is fatally wrong.
It hides *real* StringTokenizer.

 
Reply With Quote
 
Sean Washington
Guest
Posts: n/a
 
      09-10-2006

Mike Schilling wrote:
> Sean Washington wrote:
> > I could have swore I was doing everything right, but no matter what I
> > try I end up getting the following error:
> >
> > Exception in thread "main" java.lang.Error: Unresolved compilation
> > problem:
> > The constructor StringTokenizer(String, String) is undefined
> >
> > at StringTokenizer.main(StringTokenizer.java:
> >
> > Here is my code:
> >
> > import java.util.*;
> >
> > public class StringTokenizer
> > {
> > public static void main(String[] Args)
> > {
> > String ssn = "123-34-7948";
> > StringTokenizer ssnToken = new StringTokenizer(ssn, "-");
> > }
> > }
> >
> > What's am I doing wrong?

>
> Not defining a constructor for StringTokenizer. Of, if you want to
> construct a java.util.StringTokenizer, you need to say so, because you've
> asked to construct an instance of *your* StringTokenizer class. You'd need
> to say
>
> java.util.StringTokenizer ssnToken = new java.util.StringTokenizer(ssn,
> "-");
>
>
> The simplest fix is to call your class something else.


Im still really new to programming and my java 1 class is online so I
may be confusing myself here... the class name is ssnToken, correct? I
tried adding the java.util onto the StringTokenizer, but that did not
work. I use eclipse as my IDE and it tells me there error is on the new
'StringTokenizer(ssn, "-");' part of the line. It says: The constructor
StringTokenizer(String, String) is undefined

 
Reply With Quote
 
hiwa
Guest
Posts: n/a
 
      09-10-2006
Sean Washington のメッセージ:

> Mike Schilling wrote:
> > Sean Washington wrote:
> > > I could have swore I was doing everything right, but no matter what I
> > > try I end up getting the following error:
> > >
> > > Exception in thread "main" java.lang.Error: Unresolved compilation
> > > problem:
> > > The constructor StringTokenizer(String, String) is undefined
> > >
> > > at StringTokenizer.main(StringTokenizer.java:
> > >
> > > Here is my code:
> > >
> > > import java.util.*;
> > >
> > > public class StringTokenizer
> > > {
> > > public static void main(String[] Args)
> > > {
> > > String ssn = "123-34-7948";
> > > StringTokenizer ssnToken = new StringTokenizer(ssn, "-");
> > > }
> > > }
> > >
> > > What's am I doing wrong?

> >
> > Not defining a constructor for StringTokenizer. Of, if you want to
> > construct a java.util.StringTokenizer, you need to say so, because you've
> > asked to construct an instance of *your* StringTokenizer class. You'd need
> > to say
> >
> > java.util.StringTokenizer ssnToken = new java.util.StringTokenizer(ssn,
> > "-");
> >
> >
> > The simplest fix is to call your class something else.

>
> Im still really new to programming and my java 1 class is online so I
> may be confusing myself here... the class name is ssnToken, correct? I
> tried adding the java.util onto the StringTokenizer, but that did not
> work. I use eclipse as my IDE and it tells me there error is on the new
> 'StringTokenizer(ssn, "-");' part of the line. It says: The constructor
> StringTokenizer(String, String) is undefined


> public class StringTokenizer
> {

The cause of the error is you using the name of a Java core API class,
which is, or happens to be, StringTokenizer. Rename your class. How
about public class SeanWashington. The error should go away.

 
Reply With Quote
 
Sean Washington
Guest
Posts: n/a
 
      09-10-2006

hiwa wrote:
> Sean Washington のメッセージ:
>
> > Mike Schilling wrote:
> > > Sean Washington wrote:
> > > > I could have swore I was doing everything right, but no matter what I
> > > > try I end up getting the following error:
> > > >
> > > > Exception in thread "main" java.lang.Error: Unresolved compilation
> > > > problem:
> > > > The constructor StringTokenizer(String, String) is undefined
> > > >
> > > > at StringTokenizer.main(StringTokenizer.java:
> > > >
> > > > Here is my code:
> > > >
> > > > import java.util.*;
> > > >
> > > > public class StringTokenizer
> > > > {
> > > > public static void main(String[] Args)
> > > > {
> > > > String ssn = "123-34-7948";
> > > > StringTokenizer ssnToken = new StringTokenizer(ssn, "-");
> > > > }
> > > > }
> > > >
> > > > What's am I doing wrong?
> > >
> > > Not defining a constructor for StringTokenizer. Of, if you want to
> > > construct a java.util.StringTokenizer, you need to say so, because you've
> > > asked to construct an instance of *your* StringTokenizer class. You'd need
> > > to say
> > >
> > > java.util.StringTokenizer ssnToken = new java.util.StringTokenizer(ssn,
> > > "-");
> > >
> > >
> > > The simplest fix is to call your class something else.

> >
> > Im still really new to programming and my java 1 class is online so I
> > may be confusing myself here... the class name is ssnToken, correct? I
> > tried adding the java.util onto the StringTokenizer, but that did not
> > work. I use eclipse as my IDE and it tells me there error is on the new
> > 'StringTokenizer(ssn, "-");' part of the line. It says: The constructor
> > StringTokenizer(String, String) is undefined

>
> > public class StringTokenizer
> > {

> The cause of the error is you using the name of a Java core API class,
> which is, or happens to be, StringTokenizer. Rename your class. How
> about public class SeanWashington. The error should go away.


wow...I think maybe I need to go to bed.

That worked. Thanks for the help

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
StringTokenizer insert into Array?? Newbie Java 4 12-07-2003 06:19 PM
StringTokenizer Question? Jim Crowell Java 9 08-23-2003 06:28 PM
Read data with delimater using stringtokenizer Liang Yew Java 3 07-21-2003 07:10 AM
StringTokenizer help ARMANDO PADILLA Java 3 07-04-2003 04:37 PM
Re: StringTokenizer Help Phil Hanna Java 0 06-30-2003 11:57 PM



Advertisments