• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with this JAVA statement ASAP..PLEASSEEE

 
jayson clark
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Identify the mistake in the statement below :

private static public final String sabc=123456;
 
miguel lisboa
Ranch Hand
Posts: 1281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Identify the mistake in the statement below :

private static public final String sabc=123456;

i'd go for ... several
private and at same time public
if string should be ...="123456";
finally if final should be in caps like SABC
 
jayson clark
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is this right though:

public class String
(
private Final static String sabc="123456";

)


Thank you
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33691
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cathy,
Note that Java is case sensitive so "Final" should be "final".

And welcome to JavaRanch!
 
jayson clark
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK so the Corest statement is:

public class String
(
private final static String sabc="123456";

)
Thanks much
 
jayson clark
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody look at my codes if its right? pleaseeee i need to submit this tonight...

public class String
(
private final static String sabc="123456";

)
[ March 14, 2005: Message edited by: cathy sio ]
 
David Harkness
Ranch Hand
Posts: 1646
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd high recommend against creating your own class named "String". Other than that, the syntax is fine. Off hand, what happens when you compile it? If it is working, why keep asking us what's wrong with it? If it isn't working, post the error your getting.

If you haven't even tried to compile it, you can't be in that much of a hurry.
 
Nick George
Ranch Hand
Posts: 815
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A:
Brackets, not parentheses:

private class FunnyString
{
...
}

B:
What the hell are you trying to do?!
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As written, even with the braces, this won't work, because the "String" in the variable declaration will refer to the enclosing class, not to java.lang.String. You'll get an an error about "incompatible types". You need to change the name of the class.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33691
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Miguel pointed out "SABC" should be capital. While it isn't wrong, this is a good habit to get into.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic