Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Accessing string list?

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Accessing string list?

    We were suppose to make a program for an assignment and the prof provided some codes to start of. What does this basically mean? How do i access the string arrays from consolelist?

    class ConsoleInfo
    {
     
      private String conTitle;
      private double conPrice;
      private int conQty;
      private String conPic;
     
      private static String empPassword; 
     
        ConsoleInfo(String title, double price, int qty,String pic)
         {
            conTitle = title;
       	  conPrice = price;
       	  conQty = qty;
       	  conPic = pic;    	   
     
         }
       /*
     
       Finish the class off with the various set/get methods
       here
     
     */    
     public void setTitle(String a)
       {
          conTitle = a;
       }
       public String getTitle()
       {
          return conTitle;
       }
       public void setPrice(double a)
       {
          conPrice = a;
       }
       public double getPrice()
       {
          return conPrice;
       }
       public void setQty(int a)
       {
          conQty = a;
       }
       public int getQty()
       {
          return conQty;
       }
       public void setPic(String a)
       {
          conPic = a;
       }
       public String getPic()
       {
          return conPic;
       }
       public void setPass(String a)
       {
          empPassword = a;
       }
       public String getPass()
       {
          return empPassword;
       }
     
    }
     
    ///////////////////////////////
     
    class ConsoleList 
    {
     
      ConsoleInfo[] conList;
     
      public void createList()
      {
         conList = new ConsoleInfo[7];
     
    	    conList[0] = new ConsoleInfo("Xbox One",549.99,45,"xbox-one.jpg");
     
    	   conList[1] = new ConsoleInfo("Xbox 360",321.99,92,"xbox360.jpg");
    		conList[2] = new ConsoleInfo("PS4",678.99,72,"ps4.jpg");
     
    		conList[3] = new ConsoleInfo("PS3",447.99,11,"ps3.jpg");
    		conList[4] = new ConsoleInfo("Wii U",354.99,23,"wii-U.jpg");
          conList[5] = new ConsoleInfo("Sega Firecore",110.99,0,"sega-Firecore.jpg");
    	   conList[6] = new ConsoleInfo("Steam Machine",784.99,1,"steamMachine.jpg");        
      }
    }


  2. #2
    Junior Member
    Join Date
    Apr 2014
    Posts
    3
    My Mood
    Happy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Accessing string list?

    Run the below code and it will print list on console.

    GB: Code removed.
    Last edited by GregBrannon; April 9th, 2014 at 04:54 AM. Reason: Spoonfeeding

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    4,364
    My Mood
    Mellow
    Thanks
    143
    Thanked 598 Times in 585 Posts

    Default Re: Accessing string list?

    Sahil.Arora: Please review this forum's thoughts on Spoon feeding.

    In future, read the OP's question and provide an answer, a nudge in the correct direction, but not a solution to the OP's assignment.

  4. #4
    Junior Member
    Join Date
    Apr 2014
    Posts
    3
    My Mood
    Happy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Accessing string list?

    GregBrannon: Ok, I'll take care.

Similar Threads

  1. Count occurrence of a string in an array list
    By Parth Raval in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 31st, 2014, 11:04 PM
  2. Convert List<Set<String>> to string array
    By shatlav in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 4th, 2013, 07:16 AM
  3. Searching for string values in a circular list
    By hippo1974 in forum Object Oriented Programming
    Replies: 10
    Last Post: July 11th, 2011, 04:36 AM
  4. From List<String> to a generic LinkedList
    By johnrmsn@Msn.com in forum Collections and Generics
    Replies: 2
    Last Post: July 2nd, 2011, 12:46 PM
  5. store a list/string for each object
    By tommy in forum Object Oriented Programming
    Replies: 5
    Last Post: May 28th, 2010, 09:24 AM

Tags for this Thread