初次接触java,关于System.exit(0)的问题

是这样子的,我写了一个程序,输入三个数字找最大值。之后用户输入一个字符,是q的话则退出。因为要不断地重复执行,所以我使用了for的死循环,用户输入的不是q,则继续执行该for循环。
int number1,number2,number3;
String str = "yes"; //str的初始值

             Scanner input = new Scanner(System.in);
             Scanner input2 = new Scanner(System.in);
             Scanner input3 = new Scanner(System.in);
             Scanner inputCh = new Scanner(System.in);

           for (;;){
               if (str == "q")
                   System.exit(0);
                            /*程序第一次跑完后,我str的值已经透过下面的scanner输入了q,为什么第二次执行的时候这边不会结束程序?
                            我试过一开始在前面直接把str的初始值变为q,然后程序就直接结束了。但是为什么我在底部的scanner输入的q在这边却无法直接结束程序?搞不太清楚问题出在哪里?能解答一下吗? */


            System.out.println("Please enter three numbers to find biggest one");
                              System.out.println("First number");
                              number1 = input.nextInt();

                              System.out.println("Second number");
                              number2 = input2.nextInt();

                              System.out.println("Third number");
                              number3 = input3.nextInt();

                              int max = number1;
                  if (number2 > max){
                      max = number2;
                      if (number3 > max)
                          max = number3;
                          }
                       System.out.println("The biggest number is " +max);                     

                     System.out.println("Do you want to continue?(type q to end)");
                             str = inputCh.nextLine();
                                                        //我这边输入了q

             }
 }

}

不要用等号判断字符串,用xxx.equals

== 基本数据类型比较的是值,像string这样的引用数据类型比较的是地址。你应该用str.equals("q")来判断,这时比较的是值,而不是地址