java - An error with for loop -


i working on problem of string manipulation.following code snippet. not sure why code control not going inside if loop.

public class test{  public static void main(string args[]) {     scanner scan = new scanner(system.in);     int searchvariable = scan.nextint();     int numberofvalues = scan.nextint();     scan.nextline();     while (numberofvalues-- != 0) {         string strg = scan.nextline();         string[] arrayint = strg.split(" ");         (int = 0; < arrayint.length; i++) {             //   system.out.println("test 1===");            // system.out.println("i value" + i);            // system.out.println("i " + strg.charat(i));            // system.out.println(searchvariable);             if (searchvariable==strg.charat(i)) {                 system.out.println("===>");                 system.out.println("index " + i);                 return;             }          }     } } 

}

input

4

6

1 4 5 7 9 12

output

output should 4. writing code finding integer 4 in third line of input.

problem

program control not going inside loop if (searchvariable==strg.charat(i)) .please help!!

the problem in logic: want

if (searchvariable==integer.parseint(arrayint[i]))... 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -