Skip to content

Instantly share code, notes, and snippets.

@golenishchev
Created November 26, 2015 07:04
Show Gist options
  • Save golenishchev/8581da95c0f24b6ace90 to your computer and use it in GitHub Desktop.
Save golenishchev/8581da95c0f24b6ace90 to your computer and use it in GitHub Desktop.
lesson 8
public class Calculator {
private int firstNumber;
private int secondNumber;
private int resultValue;
public Calculator() { // Constructor
firstNumber = 10;
secondNumber = 5;
resultValue = getSum();
printResult(resultValue);
}
public int getSum() {
return firstNumber + secondNumber;
}
public void printResult(int resultValue) {
System.out.println("Result value: " + resultValue);
}
public static void main(String args[]) {
Calculator myCalc = new Calculator(); // Почему без этого объекта не работает вывод на 18-й строке?
// System.out.println("Result value: " + myCalc.getSum());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment