0
String ans = JOptionPane.showInputDialog(null, "S,T,R,K or P?");
if (ans == "S")
{ 
    class Square
}

基本上,我想在主类Shapes下运行这个代码,然后在if语句中我想知道如果可能的话如何在这个Shapes类中运行另一个单独的类,即

ans = S

然后它运行另一个程序,该程序在同一个 Shapes 程序中使用文本星“*”创建一个正方形。

4

1 回答 1

1

如果编码正确,那么您在问题中的要求将能够正常工作!

String ans = JOptionPane.showInputDialog(null, "S,T,R,K or P?");
if (ans.equals("S"))
{ 
    Square s = new Square();
}

广场班

public class Square {
//bla bla bla
}
于 2013-06-02T16:24:42.660 回答