Thread: Naming Methods

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Naming Methods


    I have my main class split into two methods. The second method is taking each line from the input file and sorting each word by length. However, when I try to call the method in the main class, it gives me a ".class" and "; expected" error.
    Here's where I am trying to initialize the two.
    Code:
    Scanner infile =   new Scanner( new FileReader( args[0] ) );
                PrintWriter outfile = new PrintWriter( args[1] );
                while (infile.hasNextLine())
                {
                    String[] breaker = infile.nextLine().split(" ");
                    for ( int p = 0; p < breaker.length; p++)
                    {
                    String word = breaker[p];
                    Scramble(word);
                    outfile.print(word+ " ");
    
                    }
                }
            outfile.flush();
            while (infile.hasNextLine())
            {
                String[] scrambler = infile.nextLine().split(" ");
    
                SortingLength(String[] scrambler);
            }
    And the SortingLength Method
    Code:
    public static void SortingLength (String[] line)
        {
    
        String[] tokens;
        tokens = line.split(" ");//tokens is now a split of the three lines
        String[] limitWord = "[ ]";//splitting the 3 arrays of words into their own array
    
    
    
                        //sorting the line into length by words
            int k = line.length();
            int m = 0;
            int n = 0;
            for (m = 0; m < k; m++)
            {
                for ( n = 0; n < (k-m); n++)
                {
                    if( limtWord[n] > limitWord[n+1])
                    {
                        tem = limitWord[n];
                        limitWord[n] = limitWord[n+1];
                        limitWord[n+1] = tem;
                    }
                }
            }
            int p = 0;
            for (p = 0; p < token.length(); p++)
            {
                print(limitWord[n] + " ");
            }
  2. #2
  3. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    Usually an error like that indicates a missing punctuation mark.

IMN logo majestic logo threadwatch logo seochat tools logo