Results 1 to 3 of 3
  1. #1
    minusten is offline Member
    Join Date
    Apr 2011
    Posts
    11
    Rep Power
    0

    Question strings into arrays

    Hi,

    im trying to create a class that

    takes entered input ie student name

    and adds it to an array

    the prompts "name added"

    Below is what i have

    What is arraylist how does it work?:eek:


    public class AddStudent {

    /**
    * @param args the command line arguments
    */
    public static void main(String args[])
    {
    Scanner newStudent = new Scanner (System.in);

    System.out.println("Please enter student name:"); //prompt for input
    String studentName = newStudent.nextLine(); // read line of input
    System.out.println(); //displays blank line
    System.out.println( studentName); //displays student name
    System.out.printf("has been successfully enrolled! \n");//states string

    }
    }

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    An arraylist is a list with an underlying array to hold it's elements. It resizes automatically, allowing you to add and remove items without worrying about going out of bounds. Check out the tutorials and API for more information on them. To declare and initialize an arraylist of strings you do this
    Java Code:
    ArrayList<String> strings = new ArrayList<String>();

  3. #3
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    6

    Wink

    Quote Originally Posted by minusten View Post
    What is arraylist how does it work?:eek:
    In case if you are interested : Java Tip - ArrayList

    Have a look at the API as well for various methods and details : ArrayList API

    Hope that helps,

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

Similar Threads

  1. byte arrays and strings
    By 7wb in forum New To Java
    Replies: 1
    Last Post: 11-14-2010, 10:51 PM
  2. using random strings from arrays insult generator
    By carden2 in forum New To Java
    Replies: 5
    Last Post: 04-05-2010, 06:51 AM
  3. Arrays.sort... why sorting all arrays in class?
    By innspiron in forum New To Java
    Replies: 6
    Last Post: 03-23-2010, 02:40 AM
  4. It is possible in Strings..?
    By mlibot in forum New To Java
    Replies: 1
    Last Post: 03-12-2010, 06:30 AM
  5. arrays strings and doubles
    By rgvbabe in forum New To Java
    Replies: 1
    Last Post: 01-14-2008, 12:26 AM

Tags for this Thread

Posting Permissions

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