⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testtostring.java

📁 疯狂Java讲义_源码(含Java设计模式CHM
💻 JAVA
字号:


/**
 * Description:
 * <br/>Copyright (C), 2005-2008, Yeeku.H.Lee
 * <br/>This program is protected by copyright laws.
 * <br/>Program Name:
 * <br/>Date:
 * @author  Yeeku.H.Lee kongyeeku@163.com
 * @version  1.0
 */
class Apple
{
	private String color;
	private double weight;
	public Apple(){	}
	//提供有参数的构造器
	public Apple(String color , double weight)
	{
		this.color = color;
		this.weight = weight;
	}

	public void setColor(String color)
	{
		this.color = color;
	}
	public String getColor()
	{
		 return this.color;
	}

	public void setWeight(double weight)
	{
		this.weight = weight;
	}
	public double getWeight()
	{
		 return this.weight;
	}
	public String toString()
	{		
		//return "一个苹果,颜色是:" + color + ",重量是:" + weight;
		return "Apple[color=" + color + ",weight=" + weight + "]";
	}
}
public class TestToString
{
	public static void main(String[] args) 
	{
		Apple a = new Apple("红色" , 5.68);
		System.out.println(a);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -