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

Thread: execution

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default execution

    I wrote a simple program on blueJ and compiled it successfully but when i tried to run it nothing happened.What could be the possible reason..how to fix it?


  2. #2
    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: execution

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Tried to run it or actually ran it? Because the code doesn't do anything? No way to tell without seeing the code. When you post the code, please post your code correctly per the above link.

  3. #3
    Junior Member
    Join Date
    May 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: execution

    import java.io.*;
    class arm
    {
    public static void main(String args[])throws IOException
    {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=0,c=0,i=0;
    for(i=1;i<=n;i++)
    {
    c=0;
    for(i=1;i<=n;i++)
    {
    if(n%i==0)
    c=c+1;
    }
    if(c==2)
    System.out.println(n);
    }
    }
    }

  4. #4
    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: execution

    As I asked, please post your code correctly.

    In Java, class names begin with capital letters.

    What's the BufferedReader for?

    Your code is hard to read, but I think it will only "do something" visible by printing 'n' if 'c' equals 2. When will that happen? You should trace your code line by line to see what is happening to better understand the results you're seeing or not seeing. Then, you might add some other print statements to show the values of 'n', 'c', 'i', etc. at various points to see if your code tracing was correct.

    Others like to start or end their main() method with a simple print statement like "Starting main() method," or "Leaving main() method," so that you have some confidence that the program is doing something.

    These are basic debugging techniques that you should learn and employ.

    --- Update ---

    As I asked, please post your code correctly.

    In Java, class names begin with capital letters.

    What's the BufferedReader for?

    Your code is hard to read, but I think it will only "do something" visible by printing 'n' if 'c' equals 2. When will that happen? You should trace your code line by line to see what is happening to better understand the results you're seeing or not seeing. Then, you might add some other print statements to show the values of 'n', 'c', 'i', etc. at various points to see if your code tracing was correct.

    Others like to start or end their main() method with a simple print statement like "Starting main() method," or "Leaving main() method," so that you have some confidence that the program is doing something.

    These are basic debugging techniques that you should learn and employ.

Similar Threads

  1. struts2 execution error
    By shreekrishna in forum Web Frameworks
    Replies: 0
    Last Post: April 16th, 2013, 01:31 AM
  2. finally block execution
    By peter_parker in forum Java Theory & Questions
    Replies: 2
    Last Post: April 1st, 2013, 12:54 AM
  3. Time taken for execution is more
    By rameshiit19 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 6th, 2011, 09:48 AM
  4. Question on dependency execution
    By back2grave in forum Algorithms & Recursion
    Replies: 2
    Last Post: May 2nd, 2010, 12:50 AM
  5. Not Looping? (do - while) bad execution!
    By chronoz13 in forum Loops & Control Statements
    Replies: 1
    Last Post: November 23rd, 2009, 08:51 PM