Results 1 to 7 of 7
  1. #1
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default ';' expected, not of the common kind..

    Hai!
    Im totaly lost when it comes to returning an array..

    So heres my script, Idk why I thinks my method is a statement but it does..
    So can you help me?

    Script:
    PHP Code:
     import static java.lang.System.out;
     import java.util.Scanner;
    public class Speecher {
        
        public static void main(String[] args) {
        	
        	// TODO, add your application code
        	out.println("Wellcome to speecher!");
        	Scanner text = new Scanner(System.in);
        	String chat = "";
        	chat = text.nextLine();
        	String words[] = getWords(chat);
        	for (x = 0;x<words.length;x++){
        		out.print(words[x]);
        	}
        }
        private static String getWords[](String chat){
        	//ArrayList<String> list = new ArrayList<String>();
        	String list = chat.split(" ");
        	return list;
        }
    }

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    6

    Default

    try this instead:

    Java Code:
     
    private static String[] getWords(String chat){
       //ArrayList<String> list = new ArrayList<String>();
       String[] list = chat.split(" ");
       return list;
    }
    My Hobby Project: LegacyClone

  3. #3
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    thnx this helps alot =)

  4. #4
    parul1234 is offline Member
    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0

    Default

    It was useful ... I was also facing the same problem with one of my program

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Java doc contains all the information related to this lol. If you read it carefully, this is not a big deal. As a habit try to work around with Java doc as well, you can learn a lot. Good luck :)

  6. #6
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    unlike in c/c++, a string is not simple an array of characters. and an arraylist is not an array. also, you never declare your 'x' variable, unless you didn't post your complete code

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. How to get Home directory using Common Net ftp api?
    By cprash.aggarwal in forum Networking
    Replies: 1
    Last Post: 03-01-2009, 05:37 PM
  2. how client know what kind of server
    By lemur in forum Networking
    Replies: 3
    Last Post: 05-31-2008, 07:11 AM
  3. Total Newbie, Be Kind :)
    By dazza-s in forum New To Java
    Replies: 11
    Last Post: 04-26-2008, 10:54 PM
  4. Where i have to write the common data to jsp
    By trill in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 07:35 AM
  5. Will make a pyramid of some kind out of a number
    By romina in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •