Results 1 to 6 of 6
- 04-08-2008, 08:31 PM #1
(newbie) String doesn't compile?!
Not sure why, the following code doesn't compile:
<code>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testone;
/**
*
* @author User
*/
import java.lang.*;
import java.text.*;
public class Main
{
public static void main(String[] args)
{
double x = 10000.0 / 3.0;
NumberFormat formatter = NumberFormat.getNumberInstance();
String s = formatter.format(x); // the string "3,333.33"
System.out.println(s);
}
}
</code>
<error>
init:
deps-clean:
Deleting directory C:\Documents and Settings\User\My Documents\NetBeansProjects\TestTwo\build
clean:
init:
deps-jar:
Created dir: C:\Documents and Settings\User\My Documents\NetBeansProjects\TestTwo\build\classes
Compiling 1 source file to C:\Documents and Settings\User\My Documents\NetBeansProjects\TestTwo\build\classes
C:\Documents and Settings\User\My Documents\NetBeansProjects\TestTwo\src\testtwo\Mai n.java:19: cannot find symbol
symbol : class string
location: class testtwo.Main
public static void main(string[] args) {1 error
BUILD FAILED (total time: 0 seconds)
</error>
Using NetBeans IDE 6.0
Java SE 1.6
- 04-09-2008, 02:41 AM #2
Hi Jon, when you use code tags be sure to use the [ ]'s, not the < > :)
I'm not so sure why this isn't compiling for you... I ran it and it compiles without a hitch. However, after looking at your error message, it appears you've changed the capitalization of the "String" which was lowercased "string" when you compiled- this will cause an error. Since you've capitalized, have you tried to compile your code again? Give it a shot.Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
- 04-09-2008, 04:01 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yes that code compiled and run perfectly for me. As Captain says, the compiler can't find the symbol "string" and not compiled. Normally when you get such an error, look at what error message says. You can't figured the exact error each time. But it is not difficult at all.
There in the error message you can find the line number is given, where the error is find. So it really help to find what the error is.
- 04-09-2008, 08:34 AM #4
Weird. Are you using Java 1.6?
- 04-09-2008, 08:36 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yes, I'm. Why still is it not compile?
- 04-09-2008, 08:37 AM #6
Jon, please post your new code if you've edited it in any way- heck, please post it anyways. I have a strong feeling you may have forgot that you edited your code before you posted it here. The compiler doesn't shoot out errors for no reason- the reason you posted there says "string" in lowercased, while your code is uppercase.. I really can't explain it easier than that. Please post your new code.
Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
Similar Threads
-
newbie needs help...
By vicky08 in forum New To JavaReplies: 2Last Post: 03-31-2008, 04:26 PM -
Newbie
By CSnoob87 in forum IntroductionsReplies: 2Last Post: 02-18-2008, 08:49 AM -
Newbie in applet, Help me
By barney in forum Java AppletsReplies: 1Last Post: 08-07-2007, 07:14 AM -
Help, java newbie
By baltimore in forum New To JavaReplies: 1Last Post: 08-07-2007, 12:56 AM -
newbie: the app is loaded but i can't see it
By tamayo in forum New To JavaReplies: 1Last Post: 07-21-2007, 08:14 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks