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

Thread: JAVA=CODE= public class Main { What's the problem with that line?

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

    Default JAVA=CODE= public class Main { What's the problem with that line?

    Hello everyone
    Would appreciate help
    Thank you

    public class Main {

    public static void main (String[]args) {

    int number1 = 5, number2 = 6;

    int sum = number1 + number2;

    System.out.println(sum);
    }
    }
    Attached Images Attached Images

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

    Default Re: JAVA=CODE= public class Main { What's the problem with that line?

    Can you explain what your problem is?
    Copy and paste here any error messages you are having trouble with. Not an image.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Oct 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA=CODE= public class Main { What's the problem with that line?

    public class Main {
    int number1;
    int number2;
    int sum;

    public static void main (String[]args) {
    int number1 = 5;
    int number2 = 6;
    int sum = number1 + number2;

    System.out.println(sum);
    }
    }

    you have to declare the integers in the class. if you have anymore questions feel free to message me and ask

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

    Default Re: JAVA=CODE= public class Main { What's the problem with that line?

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Oct 2019
    Posts
    2
    My Mood
    Busy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA=CODE= public class Main { What's the problem with that line?

    I found no error in these program

Similar Threads

  1. Replies: 6
    Last Post: August 16th, 2014, 01:34 AM
  2. Java, calling another public class from within the main class giving problems.
    By RandomGaisha in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 26th, 2012, 02:30 PM
  3. Replies: 2
    Last Post: November 18th, 2012, 02:09 PM
  4. Passing command line args from main to another class
    By csharp100 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 4th, 2012, 11:11 AM
  5. Replies: 3
    Last Post: June 17th, 2012, 06:22 PM