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

Thread: Runtime array programm but there is error in it.

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

    Default Runtime array programm but there is error in it.

    //
    class abc
    {
    public static void main(String ar[][])
    {
    int a[][]=new int[2][3];
    int b[][]=new int[2][3];
    int i,j,k,l;
     
    for(i=0;i<2;i++)
    	{
    	for(j=0;j<3;j++)
    		{
    		a[i][j]=Integer.parseInt(ar[i][j]);
    		System.out.print("No is="+a[i][j]);
    		}
    	System.out.println();
    	}
    }
    }	
    //


    Error is:-Main method not found in class abc


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

    Default Re: Runtime array programm but there is error in it.

    Welcome to the Forum! Thank you for taking the time to learn how to post code correctly. Please read this topic to see other useful info for newcomers.

    Please post your error(s) and ask specific questions. It's important to know that we're talking about and working to correct the same errors.

  3. #3
    Junior Member Tjones787's Avatar
    Join Date
    Jan 2014
    Location
    Lagos, Nigeira
    Posts
    16
    My Mood
    Asleep
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: Runtime array programm but there is error in it.

    What are the errors get when you run the program

    --- Update ---

    Look at your main class.. And what your program doing.
    Tjones787

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

    Default Re: Runtime array programm but there is error in it.

    Error is:-Main method not found in class abc.
    My program is to enter the value of array during runtime.

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Runtime array programm but there is error in it.

    Many/most programs have a main() method. Look at some other programs and see what is different about your main() method.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member Tjones787's Avatar
    Join Date
    Jan 2014
    Location
    Lagos, Nigeira
    Posts
    16
    My Mood
    Asleep
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: Runtime array programm but there is error in it.

    Yeah. Cause you have a problem with your main method. Check your main method and see where you are wrong. The argument passed to your main method.
    Tjones787

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

    Default Re: Runtime array programm but there is error in it.

    but this is the syntax for java.

    --- Update ---

    pls tell me the complete program.

  8. #8
    Junior Member Tjones787's Avatar
    Join Date
    Jan 2014
    Location
    Lagos, Nigeira
    Posts
    16
    My Mood
    Asleep
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: Runtime array programm but there is error in it.

    Check how other java programs main method looks like, then you get what's wrong with yours
    Tjones787

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

    Default Re: Runtime array programm but there is error in it.

    but i am able to run the program with this


    class abc
    {
    public static void main(String ar[])
    {
    int a[]=new int[10];
    for(int i=0;i<10;i++)
    {
    a[i]=Integer.parseInt(ar[i]);
    System.out.println("No is="+a[i]);
    }
    }
    }

    This is correct programm but is ID array

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Runtime array programm but there is error in it.

    i am able to run the program with this
    Can you explain what your problem is now?

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


    One possible problem I see is that the for loop control value is hardcoded as 10.
    It should use the .length attribute of the ar array.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Member
    Join Date
    Oct 2013
    Location
    United Kingdom
    Posts
    62
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: Runtime array programm but there is error in it.

    Please check if multi dimensional array can be used as argument.
    Thanks and regards,
    Sambit Swain

Similar Threads

  1. Help please i keep getting a runtime error with code that seems correct.
    By jorys22 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 8th, 2013, 04:59 AM
  2. Runtime error-- Applet program
    By amar5445 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 28th, 2013, 07:32 AM
  3. Runtime Error
    By Dennis Enya in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 24th, 2013, 12:44 PM
  4. stack project-runtime error
    By makonikor in forum What's Wrong With My Code?
    Replies: 16
    Last Post: July 31st, 2011, 02:16 PM
  5. Runtime Error
    By SyntheticD in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 10th, 2011, 04:09 PM