当我使用 String [] 数组时,如下所示:
import java.lang.String.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class JavaJoe
{
public static void main(String args[])
{
String [] day = {"Monday", "Tuesday", "Wednesday", "Thursday", "Saturday", "Sunday"};
这个的输出:
if(day[0] == ("Monday"))
{
double cost = 30;
double totalCost = 30 * 1.15; //cost including tax
money = money - totalCost;
System.out.println("It is " + day + " and Joe has to spend " + decimal.format(totalCost) + " on a new pair of shoes. He has " + decimal.format(money) + " left.");
} //if
给了我这个:
它是 [Ljava.lang.string;@1ea2dfe,Joe 必须花费 34.50 美元。他还剩 165.50 美元。
你能告诉我为什么吗?为什么不告诉我今天是星期一?提前致谢!