Results 1 to 5 of 5
  1. #1
    sonaliGrover is offline Member
    Join Date
    Sep 2014
    Posts
    2
    Rep Power
    0

    Default Takes to much time to run this code in netbeans

    Why netbeans takes a lot of time to run this code?

    import java.util.Scanner;

    public class Array1 {


    public static void main(String[] args)
    {
    int r,c;
    Scanner sc=new Scanner(System.in);
    r=sc.nextInt();
    Scanner sc1=new Scanner(System.in);
    c=sc1.nextInt();
    int ar1[][]=new int[r][c];
    System.out.println("enter the elements of 2D array:");
    for(int i=0; i<r; i++)
    {
    for(int j=0; j<c; j++)
    {
    ar1[i][j]=sc.nextInt();
    }
    }
    System.out.println("Displaying the elements of 2D array:");
    for(int i=0; i<r; i++)
    {
    for(int j=0; j<c; j++)
    {
    System.out.println(+ar1[i][j]);
    System.out.println("\t");
    }
    }
    }
    }

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Takes to much time to run this code in netbeans

    ... because you're not inputting anything? Be more specific man. How are you running it? What values do you input?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    sonaliGrover is offline Member
    Join Date
    Sep 2014
    Posts
    2
    Rep Power
    0

    Default Re: Takes to much time to run this code in netbeans

    I have just started using netbeans, this is the first program that I wrote.. After running the code (by run-> run project) it is showing a message near output window "running" from about 20 minutes and more. Can you tell why?
    Thanks in advance :)

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Takes to much time to run this code in netbeans

    Apparently because you don't understand what the code you wrote actually does.

    Java Code:
    Scanner sc=new Scanner(System.in);
    r=sc.nextInt();  // <---- expects user keyboard input, will wait forever for it
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Takes to much time to run this code in netbeans

    :-D

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Netbeans gui builder - output different at run time
    By joelBeaton in forum NetBeans
    Replies: 0
    Last Post: 04-01-2012, 02:29 PM
  2. HELP about login time and date in netbeans
    By masterpinuno in forum NetBeans
    Replies: 1
    Last Post: 03-26-2012, 10:49 AM
  3. Replies: 3
    Last Post: 12-07-2011, 07:00 AM
  4. how can I add time in my code :((
    By tentenen in forum Java Applets
    Replies: 2
    Last Post: 09-07-2011, 10:06 PM
  5. It takes very long time.....
    By iresha in forum Advanced Java
    Replies: 6
    Last Post: 05-11-2008, 02:31 AM

Posting Permissions

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