I run on the sheet knowing that every 2 indexes in the sheet form the HTTP + URL method.

Example:

list.get(0); //POST list.get(1); //loan/test?testArg=1234&id=5555555 

The result is a string

 POST/loan/test?testArg=1234&id=5555555 

Here is the code:

 for(int i=0; i<list.size(); i+=2){ System.out.println(list.get(i) + list.get(i+1)); } 

Now you need to create a separate string for each iteration and put the necessary values ​​there.

  • And what is wrong with defining an array of strings and accessing it through an iterator? - Sanek Zhitnik
  • And what's the difference, because in the end I need a specific number of string variables? - tarasula

1 answer 1

If you want to create multiple named variables , this is not possible. Variables are created at the time of writing the code, and not at the time of execution (I deliberately omit the possibility of interfering with bytecode, do not do this).

If we are talking about creating objects of type String, then you can store them in any container, for example, a list:

 List<String> result = new ArrayList<>(); for(int i=0; i<list.size(); i+=2){ result.add(list.get(i) + list.get(i+1)); } 
  • Yes, I meant the named variables. But I think that your option is also suitable. Thank you - tarasula