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 3 of 3

Thread: A question about an array

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default A question about an array

    so i have a string array of size 10. and im taking user inputs to store then in that string array and im using BufferedReader to get input from user and when a user enters more than 10 messages it should give a message saying that memory full....any thoughts on my code.....
    String[] messages = new String[10];
    int i;
     
    for (i = 1; i <=messages.length;i++)
    {
    messages[i] = clientSentence;
    outToClient.writeObject(messages[i]);
    }
    Last edited by helloworld922; October 28th, 2009 at 04:24 PM.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: A question about an array

    The only thing I can see wrong for sure is that Java's arrays start with index 0, not 1.

    for(i = 0; i < messages.length; i++)

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A question about an array

    Quote Originally Posted by helloworld922 View Post
    The only thing I can see wrong for sure is that Java's arrays start with index 0, not 1.

    for(i = 0; i < messages.length; i++)

    yah it was origionally started from 0 but i was playing around with it. yah i know there is nothing wrong with code but it still doest work. anyways i ll try it again tommorw and see where i can get....

Similar Threads

  1. Question on my math
    By SwEeTAcTioN in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 25th, 2009, 06:42 PM
  2. Regex Question
    By igniteflow in forum Java SE APIs
    Replies: 1
    Last Post: August 28th, 2009, 12:46 PM
  3. [SOLVED] Difference in the code on changing logical operators
    By lotus in forum Loops & Control Statements
    Replies: 3
    Last Post: June 20th, 2009, 04:30 AM
  4. Getting an error while altering a source code
    By marksquall in forum Collections and Generics
    Replies: 3
    Last Post: June 8th, 2009, 03:49 AM
  5. How to show 2D array using combobox and radiobutton?
    By Broken in forum Loops & Control Statements
    Replies: 1
    Last Post: March 10th, 2009, 07:01 AM