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: Arrays ?

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Arrays ?

    is there a way to store values in array. for ex : if user enters some names they all get stored in a String name [] array. I need this so I can make a table of names. help please


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,301
    My Mood
    Hungover
    Thanks
    142
    Thanked 620 Times in 531 Posts

    Default Re: Arrays ?

    Sure. What have you tried? Where are you stuck?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 2 Times in 1 Post

    Default Re: Arrays ?

    Yes we can do.
    The code goes like this..

    import java.util.*;

    class StringDemo{
    public static void main(String a[]){
    String s[]=new String[5];
    String name="";
    Scanner in=new Scanner(System.in); //For command line argument
    System.out.println("\n Enter name:");
    for(int i=0;i<5;i++)
    {
    name=in.next();
    s[i]=name;
    }

    System.out.println("\n The string contains:");
    for(int i=0;i<5;i++)
    System.out.println(s[i]);
    }
    }//End class

  4. The Following 2 Users Say Thank You to sudhasbhaskari For This Useful Post:

    djl1990 (November 26th, 2012), nhiap6 (November 18th, 2012)

  5. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Arrays ?

    spoon fed answer placed under moderation. sudhsbhakari, please give suggestions on how the original poster can succeed and create his own solution. Please don't just spit out a solution as this won't teach the OP anything other than how to beg for help.

Similar Threads

  1. Can Anyone Help With Arrays?
    By metaleddie13 in forum Collections and Generics
    Replies: 9
    Last Post: November 15th, 2011, 11:12 PM
  2. 2d arrays help
    By gonfreecks in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 27th, 2010, 04:27 PM
  3. arrays
    By dwamalwa in forum Java Theory & Questions
    Replies: 4
    Last Post: November 27th, 2010, 12:44 AM
  4. Arrays
    By mlan in forum Java Theory & Questions
    Replies: 2
    Last Post: February 26th, 2010, 09:23 AM
  5. 2d Arrays
    By mgutierrez19 in forum Collections and Generics
    Replies: 5
    Last Post: October 27th, 2009, 04:08 PM