问题描述
下面提到的代码声明为实例变量,并且我在类内部和方法外部执行了加法运算
int a = 10; a = a + 10;
解决方法
在Java中,方法负责对实例变量执行操作。如果需要初始化实例变量,则可以使用构造函数或初始化程序块。 您可以执行以下操作:
const o = { /*...*/ },// the 'store' JSON object from above
res1 = jsonPath(o,"$..author").toJSONString(); // all authors JSONPath expression
res2 = jsonPath(o,"$..author",{resultType:"PATH"}).toJSONString();
,
在Java int a=10; a=a+10;
中是不可能的。但您可以尝试一下,可能对您有所帮助。
public class AddOutsideMethod {
private static int i = 10;
private static int j = i + 10;
public static void main(String[] args) {
System.out.println(j);
}
}