问题
all of the variables above have the warning in the title. Could you please tell me why that is happening?
public class DataTypes {
public static void main(String[] argv) {
// new feature in JDK 7
int x = 0b1010; // 12
int y = 0b1010_1010;
int ssn = 444_12_7691;
long phone = 408_777_6666L;
double num = 9_632_401_909.1_0_3;
String twoLine = "line one\nline two";
}
}
回答1:
The variables you declared are never used, only assigned to, therefore you're being warned.
回答2:
You have defined the variables: x
, y
, ssn
, phone
, num
and twoLine
.
But you never use the variables anywhere in the code.
For instance, if you print the variables out:
System.out.println(x + y + ssn + phone + num + twoLine);
All the warnings should disappear
来源:https://stackoverflow.com/questions/36728961/the-value-of-the-local-variable-is-not-used