the local variable may not have been initialized
Eu procurei alguns casos, mas nenhum me ajudava, acredito que esse é diferente. A variável não foi iniciada em outra classe.
Classe principal
else if ("Multiplication".equals(choice)){
System.out.print("Enther the quantity of the numbers: ");
byte n = sc.nextByte();
int nulo = 0;
System.out.println();
System.out.println("Enter the numbers: ");
for (int i = 0; i<n; i++){
int numbers = sc.nextInt();
int alt = numbers;
int result = numbers * alt;
ent= new entities(result);
}
System.out.println();
System.out.print(ent);
}
Classe secundária
public class entities {
private int result;
public entities(int result){
this.result = result;
}
public int getResult(){
return result;
}
public void setResult(int result){
this.result = result;
}
}
Eu fiquei confuso, pois meu professor fez do mesmo jeito e deu certo (foi feito em outro exercício)
Como ele fez:
Classe secundária
private int number;
private String holder;
private double balance;
public Account(int number, String holder) {
this.number = number;
this.holder = holder;
}
public Account(int number, String holder, double initialDeposit) {
this.number = number;
this.holder = holder;
deposit(initialDeposit);
}
public int getNumber() {
return number;
}
public String getHolder() {
return holder;
}
public void setHolder(String holder) {
this.holder = holder;
}
public double getBalance() {
return balance;
}
public void deposit(double amount) {
balance += amount;
}
public void withdraw(double amount) {
balance -= amount + 5.0;
}
public String toString() {
return "Account "
+ number
+ ", Holder: "
+ holder
+ ", Balance: $ "
+ String.format("%.2f", balance);
}
Classe principal
Account account;
System.out.print("Enter account number: ");
int number = sc.nextInt();
System.out.print("Enter account holder: ");
sc.nextLine();
String holder = sc.nextLine();
System.out.print("Is there an initial deposit (y/n)? ");
char response = sc.next().charAt(0);
if (response == 'y') {
System.out.print("Enter initial deposit value: ");
double initialDeposit = sc.nextDouble();
account = new Account(number, holder, initialDeposit);
}
else {
account = new Account(number, holder);
}
System.out.println();
System.out.println("Account data:");
System.out.println(account);
System.out.println();
System.out.print("Enter a deposit value: ");
double depositValue = sc.nextDouble();
account.deposit(depositValue);
System.out.println("Updated account data:");
System.out.println(account);
System.out.println();
System.out.print("Enter a withdraw value: ");
double withdrawValue = sc.nextDouble();
account.withdraw(withdrawValue);
System.out.println("Updated account data:");
System.out.println(account);
sc.close();
Onde ele iniciou?
Desculpa se o post ficou muito grande. Não pensei num jeito de resumir isso 


