Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-22-2008, 06:55 AM
antgaudi's Avatar
Member
 
Join Date: Sep 2008
Location: Houston-TX
Posts: 22
Rep Power: 0
antgaudi is on a distinguished road
Default Error: LengthCharAt.java:3: ';' expected public static void main (String[] args)
I keep getting this error for the code below:
LengthCharAt.java:3: ';' expected public static void main (String[] args)

What am I doing wrong?
Thanks.

public class LengthCharAt
{
public static void main (String[] args)
private static void StringMethod()
{
String stringVariable = new String("helo");
String[ ] stringArray = {"abcd", "f", "wxy", "kl"};
stringVariable=stringVariable.charAt
(stringArray[3].length()) + stringVariable;
System.out.println(stringVariable);
}
}
__________________
"The minute you settle for less than you deserve, you get even less than you settled for." Maureen Dowd
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-22-2008, 07:11 AM
serjant's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 451
Rep Power: 2
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
Default
You cannot declare one method in another,as you did.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-22-2008, 07:27 AM
antgaudi's Avatar
Member
 
Join Date: Sep 2008
Location: Houston-TX
Posts: 22
Rep Power: 0
antgaudi is on a distinguished road
Default
so how could this code work? thanks.
__________________
"The minute you settle for less than you deserve, you get even less than you settled for." Maureen Dowd
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-22-2008, 08:33 AM
serjant's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 451
Rep Power: 2
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
Default
Code:
public class LengthCharAt
{
    public static void StringMethod()
    { 
         String stringVariable = new String("helo");
         String[ ] stringArray = {"abcd", "f", "wxy", "kl"};
         stringVariable=stringVariable.charAt(stringArray[3].length())+stringVariable;
         System.out.println(stringVariable);
     }
     public static void main (String[] args)
    {
           new LengthChartAt().StringMethod();
    }
}
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-22-2008, 10:12 PM
antgaudi's Avatar
Member
 
Join Date: Sep 2008
Location: Houston-TX
Posts: 22
Rep Power: 0
antgaudi is on a distinguished road
Default
I keep getting error for line 12: java:12: cannot find symbol
symbol : class LengthChartAt
location: class LengthCharAt
new LengthChartAt().StringMethod();

dunno...
__________________
"The minute you settle for less than you deserve, you get even less than you settled for." Maureen Dowd
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 11-22-2008, 10:23 PM
antgaudi's Avatar
Member
 
Join Date: Sep 2008
Location: Houston-TX
Posts: 22
Rep Power: 0
antgaudi is on a distinguished road
Default
are you a java tutor or do you know any?
__________________
"The minute you settle for less than you deserve, you get even less than you settled for." Maureen Dowd
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 11-22-2008, 10:37 PM
serjant's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 451
Rep Power: 2
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
Default
there is an error,remove letter "t",the name of the class was pselled wrong

Code:
new LengthCharAt().StringMethod();
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 11-22-2008, 10:55 PM
serjant's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 451
Rep Power: 2
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
Default
Originally Posted by antgaudi View Post
are you a java tutor or do you know any?
What kind of question is that?What did you mean by that?
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 11-22-2008, 10:59 PM
antgaudi's Avatar
Member
 
Join Date: Sep 2008
Location: Houston-TX
Posts: 22
Rep Power: 0
antgaudi is on a distinguished road
Default
if you teach java because I need help to pass an exam at the university.
__________________
"The minute you settle for less than you deserve, you get even less than you settled for." Maureen Dowd
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 11-22-2008, 11:03 PM
serjant's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 451
Rep Power: 2
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
Default
I work in this area.If you want to ask some specific questions,you can write a private message.

Last edited by serjant; 11-22-2008 at 11:06 PM.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why can't we write main without String args[] shailender New To Java 4 11-05-2008 10:58 AM
[SOLVED] Why main() in java is declared as public static void main? piyu.sha New To Java 5 10-06-2008 12:11 AM
calling a public void method from a class button supa_kali_frajilistik AWT / Swing 4 05-23-2008 01:05 PM
The different of static void,protected,and void in methods? Winarto New To Java 5 01-24-2008 11:53 PM


All times are GMT +2. The time now is 03:00 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org