Java : max of 2 integers

-  
Hello,

I am a beginner in Java, with Java 1.5.9

I want to create a small program that gives the max between two integers: as follows

public class Max //max between two integers
{
public static void main(String args[])
{
int nb1, nb2;
nb1 = Keyboard.readInt("Enter an integer:");
nb2 = Keyboard.readInt("Enter an integer:");
if (nb1 > nb2)
System.out.println("the largest integer is " + nb1);
else
System.out.println("the largest integer is " + nb2);
}
}

Java reports an error at 'k' (Keyboard) and the dot before println

How can I fix the error, thank you.
Configuration: Windows XP Firefox 3.0.4

6 answers

  1. Yes, I understand now

    instead of writing: System.out.println("the largest integer is ", nb2);

    we write: System.out.println("the largest integer is " + nb2); it’s not like the Pascal language

    is the program now running correctly

    thank you again my brother, it really means a lot
  2. but I do not want to concatenate

    the problem is in the instruction: System.out.println("the largest integer is ", nb2); Java reports the error at the second point
    1. I am really sorry, because I tried to trigger a new message in the forum while I was responding to you

      your response is wonderful, thank you my brother it works very, very well for the first problem

      now we still need to address the second error case: the error signal at the point before println

      forgive me once again, thank you
      1. Contributor
        Remplace la + un +
        En java pour concaténer une variable à une chaîne on utilise l'opérateur +
        --
        Google est votre ami, pensez y avant de poster !
    2. Can someone help me or where can I find French documentation on all Java classes and methods?

      1. Contributor
        Hey!
        If my help doesn't suit you, at least have the courtesy to tell me why...
        --
        Google is your friend, keep that in mind before posting!
    3. I didn't quite understand, what statement do I make and how?
      1. Contributor
        Use the Scanner class instead, it's cleaner (for me)

        import java.util.Scanner; (note this at the beginning of the class)

        Then in your main
        Scanner keyb = new Scanner(System.in);

        Then in your program when you want to read keyboard input you do a:

        Integers: keyb.nextInt();

        --
        Google is your friend, think about it before posting!
    4. Contributor
      Hello,

      Where is your keyboard from? Did you declare it somewhere?
      --
      Google is your friend, think about it before posting!