问题:制表符输出问题
public class Order {
static List<Dish> dishList= new ArrayList<>();
public static void main(String[] args) {
System.out.println("-----主菜单---------");
initDish();
//System.out.println(dishList);
for (Dish d:dishList) {
System.out.println(d);
System.out.println(d.id+'\t'+d.name+'\t'+d.price);
}
}
public static void initDish(){
Dish food1 = new Dish(1, "香辣肉丝", 29.00);
dishList.add(food1);
Dish food2 = new Dish(2, "炖王八", 59.00);
dishList.add(food2);
Dish food3 = new Dish(3, "地三鲜", 15.00);
dishList.add(food3);
dishList.add(new Dish(4,"凉菜",24.0));
dishList.add(new Dish(5,"佛跳墙",100.0));
}
}
运行结果:
-----主菜单---------
com.xiangmu.Dish@1b6d3586
10香辣肉丝 29.0
com.xiangmu.Dish@4554617c
11炖王八 59.0
com.xiangmu.Dish@74a14482
12地三鲜 15.0
com.xiangmu.Dish@1540e19d
13凉菜 24.0
com.xiangmu.Dish@677327b6
14佛跳墙 100.0
详细描述:
System.out.println(d.id+'\t'+d.name+'\t'+d.price);
当第一个制表符用单引号的时候,出现上边结果。如果改为双引号则没有问题,请问是什么原因导致的。