问答详情
源自:-

为什么输入的字符串无法识别

package com.imooc2;

import java.util.Scanner;

public class Initail2 {


public static void main(String[] args) {

// TODO Auto-generated method stub

  System.out.println("请输入形状:");

  Scanner s = new Scanner(System.in);

  String str = null;

  str = s.next();

  if(str=="圆形") {

  shape shape1=new circle();

  shape1.girth();

  }

  else if(str=="矩形"){

  shape shape2=new rectangle();

  shape2.girth();}

  else{

  System.out.println("请输入圆形或矩形");

  }

  System.out.println(str);

 

}


}

运行的时候 输入 圆形和矩形 不会识别

提问者:edawrdzk 2015-06-22 16:20
微课

个回答

  • 康振宁
    2015-06-23 11:51:13

    有什么错误提示吗?