|
|
|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

04-08-2008, 10:31 PM
|
|
Member
|
|
Join Date: Feb 2008
Posts: 23
|
|
|
(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, 04:41 AM
|
 |
Moderator
|
|
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
|
|
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.
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. !
Got a little Capt'n in you? (drink responsibly)
|
|

04-09-2008, 06:01 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,376
|
|
|
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

04-09-2008, 10:34 AM
|
|
Member
|
|
Join Date: Feb 2008
Posts: 23
|
|
|
Weird. Are you using Java 1.6?
|
|

04-09-2008, 10:36 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,376
|
|
|
Yes, I'm. Why still is it not compile?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

04-09-2008, 10:37 AM
|
 |
Moderator
|
|
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
|
|
|
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.
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. !
Got a little Capt'n in you? (drink responsibly)
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
All times are GMT +3. The time now is 08:51 PM.
|
|
VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org