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.

Page 1 of 2 12 LastLast
Results 1 to 25 of 26

Thread: HIIIIIIIIIIIIIIIII

  1. #1
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default HIIIIIIIIIIIIIIIII

    package javaapplication37;



    public class JavaApplication37{

    {
    public static void main(String s[]) // ilegal start uppppppp frnd
    {
    s =new String[] {"aa","bb"};
    String name=s[0];
    String add=s[1];
    System.out.println("welcome"+name);
    System.out.println("Address"+add);
    s[0]="aa";
    s[1]="bb";
    }




    }
    --- Update ---

    [/COLOR]PLZ HELP ME AS IM BEGINNER

  2. #2
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default hiiiiiiiiiiii m ajay

    package javaapplication37;



    public class JavaApplication37{

    {
    public static void main(String s[]) // m getting error while running in netbeans illegal start expression
    {

    String name=s[0];
    String add=s[1];
    System.out.println("Welcome"+name);
    System.out.println("Adress"+add);

    }




    }

    --- Update ---

    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at javaapplication37.JavaApplication37.main(JavaAppli cation37.java:12)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

    --- Update ---

    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at javaapplication37.JavaApplication37.main(JavaAppli cation37.java:12)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

    --- Update ---

    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at javaapplication37.JavaApplication37.main(JavaAppli cation37.java:12)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    Can you explain what your problem is? Copy the full text of the error message and paste it here.

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    --- Update ---

    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at javaapplication37.JavaApplication37.main(JavaAppli cation37.java:12)
    At line 12 the code used an invalid index in an array. The array is empty and does not have a first element at index 0. The program should use the array's .length attribute to test the length of the array before trying to access its elements. If there are not elements in the array, it should skip trying to access the array's elements.

    Why is the code trying to access the elements in the s array? Where you given instructions with the assignment about how to execute the program so there would be elements in the s array?
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    so wat to do changes

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    Test the length of the array and don't try to access its elements if there are not enough elements in the array.

    Why is the code trying to access the elements in the s array? Where you given instructions with the assignment about how to execute the program so there would be elements in the s array?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Unhappy Re: HIIIIIIIIIIIIIIIII

    frnd m getting error in main method in netbeans that illegal startup

    --- Update ---

    can u say me yyy wats a problem in main method

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    The s array is empty. The code tries to access its first and second elements. The JVM throws an exception: ArrayIndexOutOfBoundsException because there are no elements in the array.

    I've asked this question two times before. Please answer it>
    Why is the code trying to access the elements in the s array? Where you given instructions with the assignment about how to execute the program so there would be elements in the s array?
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    so wat is a solution for it wat changes should i do in the code so that i can no get error plz make a changes in the code and send plzzz

  9. #9
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    Please give your threads useful titles, and post your code in code or highlight tags. Read this topic to learn how to post code correctly and other useful info for new members.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    Once more:

    Why is the code trying to access the elements in the s array? Where you given instructions with the assignment about how to execute the program so there would be elements in the s array?
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    so wat to do in order to give instruction just edit the code and message meeeeeeeeeeee

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    Can you see the question I have posted? Please answer it.
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    frnd i want to get output as name + adress using array

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    i want to get output as name + adress using array
    Then you need to put something into the array BEFORE trying to access it. Assign some values to the s array before trying to access its elements:
    s=new String[]{"aa", "bb"}; //  define an array with 2 elements
    If you don't understand my answer, don't ignore it, ask a question.

  15. #15
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    can u do changes in my code plz still geting error

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    geting error
    Please copy the full text of the error message and paste it here.

    Also post the code and be sure to wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  17. #17
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    package javaapplication37;



    public class JavaApplication37{

    {
    public static void main(String s[])
    {
    s =new String[] {"aa","bb"}
    String name=s[0];
    String add=s[1];
    System.out.println("welcome"+name);
    System.out.println("Address"+add);

    }




    }

  18. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  19. #19
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    done frnd just now rectify edit code so that code i can run in netbeans

  20. #20
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    you can not assign the array of String to another String because there is no argument in the array

  21. #21
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    arguments means wat exactly can u plz write a code wee exactly ineed to change in which line

  22. #22
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    you can not assign the array of String to another String because there is no argument in the array
    @sainisuresh101 Can you post some code that shows what you are talking about?

    @AJAY KAMBLE
    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    Also post the full text of the error message.
    If you don't understand my answer, don't ignore it, ask a question.

  23. #23
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    public class Test extends Object
    {

    public static void main(String s[]) // M GETTING ERROR IN NETBEANS THAT ILLEGAL START UP
    {
    s=new String[2];

    String name=s[0];
    String add=s[1];
    System.out.println("Welcome"+name);
    System.out.println("Adress"+add);

    }
    }

    can run u can also give enter data in s[0]="ss";
    s[1]="dd";
    also the print it

  24. #24
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at javaapplication37.JavaApplication37.main(JavaAppli cation37.java:12)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

  25. #25
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HIIIIIIIIIIIIIIIII

    welcomeaa
    Addressbb
    BUILD SUCCESSFUL (total time: 0 seconds)
    it came but there was error in main method illegal start upp frnd

Page 1 of 2 12 LastLast

Tags for this Thread