Results 1 to 2 of 2
  1. #1
    nobody58 is offline Member
    Join Date
    Mar 2010
    Posts
    14
    Rep Power
    0

    Default need help linking the array

    hi I'm new to java and I've never used an array from another class

    well I got this class called wordguesser which is my main class

    Java Code:
    import java.util.*;
    
    
    // this is the class
    public class WordGuesser {
    private InputReader input;
    private words arraylist;
    
    
    
    public static String word = null;
        public void main() {
           
            reader = new InputReader();
            String inputLine= reader.nextline();
            System.out.println("guess the word?");
            word = input.nextLine();
    
         
         
         
            }
    
    
    
    
      if (get.words == word){
               System.out.println ("you won");
            
            }
               while (get.words != word){
               
               System.out.println ("you lost");
               word = input.nextLine();
    
                    }
                }
            
            }
        }
    and I need to link it to this array so that if the user enters a word that is in the array it will show a messege that says you won

    but if its not it will say you lost


    this is the array

    Java Code:
    public class words {
    
        
         public static void main(String[] args) {
              String [] words;              // declares an array of integers
    
              words = new String [15];      // allocates memory for 10 integers
                
              words[0] = "hello"; // initialize first element
              words[1] = "car"; // initialize second element
              words[2] = "dog"; 
              words[3] = "plane";
              words[4] = "plant";
              words[5] = "help";
              words[6] = "job";
              words[7] = "java";
              words[8] = "blue";
              words[9] = "bathroom";
              words[10] = "word";
              words[11] = "apple";
              words[12] = "orange";
              words[13] = "paper";
              words[14] = "stone";
    
            
         }
    }

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

Similar Threads

  1. Linking Jframes
    By nonabhai in forum AWT / Swing
    Replies: 2
    Last Post: 03-04-2010, 03:44 PM
  2. linking to a web page
    By Juuno in forum Advanced Java
    Replies: 7
    Last Post: 05-01-2009, 03:47 PM
  3. static linking
    By Nicholas Jordan in forum Advanced Java
    Replies: 35
    Last Post: 03-14-2009, 10:17 PM
  4. linking 2 Jframes
    By suhaib1thariq in forum New To Java
    Replies: 9
    Last Post: 02-13-2009, 02:30 AM
  5. Linking of exe files
    By archu2friends in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 02-06-2008, 07:08 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
  •