Java 将变量的值更改为另一个变量的值

Java 将变量的值更改为另一个变量的值,java,Java,我正在尝试通过函数“IF”将每个级别的变量NO_OF_QUESTIONS_的值从值9更改为19 我的代码中的错误是什么?如果逻辑正常。缺少返回值int。这是一个简单的问题,你应该学会自己测试它 public class ifTTest { public static int NO_OF_QUESTIONS_PER_LEVEL = 9; public static void main( String[] args ) { int[] testVectors = { 1,

我正在尝试通过函数“IF”将每个级别的变量NO_OF_QUESTIONS_的值从值9更改为19

我的代码中的错误是什么?

如果逻辑正常。缺少返回值
int
。这是一个简单的问题,你应该学会自己测试它

public class ifTTest {

   public static int NO_OF_QUESTIONS_PER_LEVEL = 9;

   public static void main( String[] args ) {
      int[] testVectors = { 1, 10, 9, };
      int[] testOutput =  {10, 11, 19 };
      for( int test=0; test < testVectors.length; test++ ) {
         NO_OF_QUESTIONS_PER_LEVEL = testVectors[test];
         NO_OF_QUESTIONS_PER_LEVEL( null );
         if( NO_OF_QUESTIONS_PER_LEVEL != testOutput[test] )
            System.out.println( "error" );
      }
   }

   public static int NO_OF_QUESTIONS_PER_LEVEL( int[] args ) {
      if( NO_OF_QUESTIONS_PER_LEVEL == 10 ) {
         NO_OF_QUESTIONS_PER_LEVEL = 11; //i want change value to 11
      } else if( NO_OF_QUESTIONS_PER_LEVEL == 9 ) {
         NO_OF_QUESTIONS_PER_LEVEL = 19; //i want change value to 19
      } else {
         NO_OF_QUESTIONS_PER_LEVEL = 10; //
      }
      return 0;
   }

}
公共类测试{
每个级别的公共静态问题数量=9;
公共静态void main(字符串[]args){
int[]testVectors={1,10,9,};
int[]testOutput={10,11,19};
for(int test=0;test
为什么要将
int[]
作为参数传递?提示:学习遵循Java命名约定。方法名称应以小写字母开头,而不应全部为大写。只有常量(一个不变的变量)应该用大写字母命名。提示#2:由Oracle免费进行研究。我是java和android研究的begginer,代码不可编译。。。或者在哪里返回方法签名中所述的整数值?参数
args
的用途是什么?看起来您只是从Java
main
方法复制了它,并出于任何原因将其更改为
int
类型
public class ifTTest {

   public static int NO_OF_QUESTIONS_PER_LEVEL = 9;

   public static void main( String[] args ) {
      int[] testVectors = { 1, 10, 9, };
      int[] testOutput =  {10, 11, 19 };
      for( int test=0; test < testVectors.length; test++ ) {
         NO_OF_QUESTIONS_PER_LEVEL = testVectors[test];
         NO_OF_QUESTIONS_PER_LEVEL( null );
         if( NO_OF_QUESTIONS_PER_LEVEL != testOutput[test] )
            System.out.println( "error" );
      }
   }

   public static int NO_OF_QUESTIONS_PER_LEVEL( int[] args ) {
      if( NO_OF_QUESTIONS_PER_LEVEL == 10 ) {
         NO_OF_QUESTIONS_PER_LEVEL = 11; //i want change value to 11
      } else if( NO_OF_QUESTIONS_PER_LEVEL == 9 ) {
         NO_OF_QUESTIONS_PER_LEVEL = 19; //i want change value to 19
      } else {
         NO_OF_QUESTIONS_PER_LEVEL = 10; //
      }
      return 0;
   }

}