I'm attempting to learn Java. I'm finding it to be frustrating and quite foreign from most other languages. I have something here typed exactly as the book has it. According to the book, it should be working, but it's not. Any tips would be SO great! I really feel like an idiot asking for help with this simplistic of a program.
import java.util.Scanner;
public class Addition
{
public static void main(String[] args)
{
Scanner input == new Scanner(System.in);
int num1; //first num to add
int num2; //second num to add
int sum; //sum of added nums
System.out.print("Enter first integer: ");
num1 = input.nextInt(); //read first num from user
System.out.print("Enter second integer: ");
num2 = input.nextInt(); //read second num from user
sum = num1 + num2; //add numbers
System.out.printf("Sum is %d\n", sum); //display sum
}
}
It's the lines
Scanner input == new Scanner(System.in);
num1 = input.nextInt(); //read first num from user
that NetBeans isn't liking. It says "variable input might not have been initialized".