 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jeremy Guest
|
Posted: Thu Mar 29, 2007 7:10 am Post subject: Compiler warning Question |
|
|
As you can see, My program compiled and run, but I got a warning on that,
and I was wondering what that means? In my program, I used Stringtokenizer
and stack to reverse a string, and I think it has to do with stack?
also how can I recompile with -Xlint ?
Note:StackReverse.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Process completed. |
|
| Back to top |
|
 |
Lew Guest
|
Posted: Thu Mar 29, 2007 7:10 am Post subject: Re: Compiler warning Question |
|
|
Jeremy wrote:
| Quote: | As you can see, My program compiled and run, but I got a warning on that,
|
We can't see what you don't show.
| Quote: | and I was wondering what that means? In my program, I used Stringtokenizer
|
Are you referring to StringTokenizer? If not, you will need to give us a link
to the docs for what you are talking about. If so, you will need to spell it
correctly for it to compile.
| Quote: | and stack to reverse a string, and I think it has to do with stack?
|
What stack implementation are you using?
| Quote: | also how can I recompile with -Xlint ?
|
Add the -Xlint option to your 'javac' command line.
| Quote: | Note:StackReverse.java uses unchecked or unsafe operations.
|
This error message comes from using "raw types", that is, non-generic forms
for classes that were declared generic.
| Quote: | Note: Recompile with -Xlint:unchecked for details.
|
This compiler option will turn those warnings into specific errors.
| Quote: | Process completed.
|
But yours isn't. You have provided no SSCCE, and a real dearth of details.
There isn't enough information here to give any kind of detailed help.
-- Lew |
|
| Back to top |
|
 |
Jeremy Guest
|
Posted: Fri Mar 30, 2007 7:07 am Post subject: Re: Compiler warning Question |
|
|
I commented out every block of the code, and I found out this section of
the code was the reason why I got a warning from the compiler.
String text = "ABC stands for Another Bad Creation found in early
1990's";
Stack stack = new Stack();
// this statement will break the string into the words which are
separated by space.
StringTokenizer temp = new StringTokenizer(text);<--- is this the
culprit?
// push all the words to the stack one by one
while (temp.hasMoreTokens())
{
stack.push(temp.nextElement());
}
I'm using JCreater LE and It basically just run and compile the program
from the software, instead of command line.
"Lew" <lew (AT) nospam (DOT) lewscanon.com> wrote in message
news:sJednbS-9v6ippbbnZ2dnUVZ_s6onZ2d (AT) comcast (DOT) com...
| Quote: | Jeremy wrote:
As you can see, My program compiled and run, but I got a warning on that,
We can't see what you don't show.
and I was wondering what that means? In my program, I used
Stringtokenizer
Are you referring to StringTokenizer? If not, you will need to give us a
link to the docs for what you are talking about. If so, you will need to
spell it correctly for it to compile.
and stack to reverse a string, and I think it has to do with stack?
What stack implementation are you using?
also how can I recompile with -Xlint ?
Add the -Xlint option to your 'javac' command line.
Note:StackReverse.java uses unchecked or unsafe operations.
This error message comes from using "raw types", that is, non-generic
forms for classes that were declared generic.
Note: Recompile with -Xlint:unchecked for details.
This compiler option will turn those warnings into specific errors.
Process completed.
But yours isn't. You have provided no SSCCE, and a real dearth of details.
There isn't enough information here to give any kind of detailed help.
-- Lew |
|
|
| Back to top |
|
 |
Bart Cremers Guest
|
Posted: Fri Mar 30, 2007 1:59 pm Post subject: Re: Compiler warning Question |
|
|
On Mar 30, 4:07 am, "Jeremy" <jltuc...@comcast.net> wrote:
| Quote: | I commented out every block of the code, and I found out this section of
the code was the reason why I got a warning from the compiler.
String text = "ABC stands for Another Bad Creation found in early
1990's";
Stack stack = new Stack();
// this statement will break the string into the words which are
separated by space.
StringTokenizer temp = new StringTokenizer(text);<--- is this the
culprit?
// push all the words to the stack one by one
while (temp.hasMoreTokens())
{
stack.push(temp.nextElement());
}
I'm using JCreater LE and It basically just run and compile the program
from the software, instead of command line.
"Lew" <l...@nospam.lewscanon.com> wrote in message
news:sJednbS-9v6ippbbnZ2dnUVZ_s6onZ2d (AT) comcast (DOT) com...
Jeremy wrote:
As you can see, My program compiled and run, but I got a warning on that,
We can't see what you don't show.
and I was wondering what that means? In my program, I used
Stringtokenizer
Are you referring to StringTokenizer? If not, you will need to give us a
link to the docs for what you are talking about. If so, you will need to
spell it correctly for it to compile.
and stack to reverse a string, and I think it has to do with stack?
What stack implementation are you using?
also how can I recompile with -Xlint ?
Add the -Xlint option to your 'javac' command line.
Note:StackReverse.java uses unchecked or unsafe operations.
This error message comes from using "raw types", that is, non-generic
forms for classes that were declared generic.
Note: Recompile with -Xlint:unchecked for details.
This compiler option will turn those warnings into specific errors.
Process completed.
But yours isn't. You have provided no SSCCE, and a real dearth of details.
There isn't enough information here to give any kind of detailed help.
-- Lew
|
The error message comes from using the stack without defining the
generic type of the stack. To get information about this when
compiling the compiler tells you to recompile using the option, so
java -Xlint:unchecked ...
You can easily solve this (but you don't have to, as it is simply a
warning) two ways. Add the annotation @SuppressWarnings("unchecked")
to the method containing the violating code, or infer generic type
arguments on the stack:
Stack<String> stack = new Stack<String>();
Using this you can only add Strings to the stack (enforced at compile
time) and retrieving Strings from the stack can be done without
casting.
Regards,
Bart |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|