public class Example{
public static void main(String[] args){
System.out.println("Testing tripvalue:");
double percent=10;
System.out.println("before:"+percent);
tripvalue(percent);
System.out.println("after:"+percent);
System.out.println("************************");
System.out.println("Testing tripleSalary :");
Employee bob=new Employee("bob",5000);
System.out.println("before:"+bob.getSalary());
bob.raiseSalary(15);
System.out.println("after:"+bob.getSalary());
}
public static void tripvalue(double x)
{
x=3*x;
System.out.println("x is :"+x);
}
}class Employee //这里提示“the type Employee is already defined”
{
public Employee(String n,double s)
{
this.name=n;
this.salary=s;
}
public String getName(){
return name;
}
public double getSalary(){
return salary;
}
public void raiseSalary(double byPercent)
{
double raise=salary * byPercent /100;
salary+=raise;
}
private String name;
private double salary;
}-----------------
class Employee //这里提示“the type Employee is already defined”
就是这句出的问题,java2核心技术的例子
public static void main(String[] args){
System.out.println("Testing tripvalue:");
double percent=10;
System.out.println("before:"+percent);
tripvalue(percent);
System.out.println("after:"+percent);
System.out.println("************************");
System.out.println("Testing tripleSalary :");
Employee bob=new Employee("bob",5000);
System.out.println("before:"+bob.getSalary());
bob.raiseSalary(15);
System.out.println("after:"+bob.getSalary());
}
public static void tripvalue(double x)
{
x=3*x;
System.out.println("x is :"+x);
}
}class Employee //这里提示“the type Employee is already defined”
{
public Employee(String n,double s)
{
this.name=n;
this.salary=s;
}
public String getName(){
return name;
}
public double getSalary(){
return salary;
}
public void raiseSalary(double byPercent)
{
double raise=salary * byPercent /100;
salary+=raise;
}
private String name;
private double salary;
}-----------------
class Employee //这里提示“the type Employee is already defined”
就是这句出的问题,java2核心技术的例子
楼主【wolfs】截止到2008-06-28 11:05:37的历史汇总数据(不包括此帖):
发帖数:72 发帖分:2200
结贴数:68 结贴分:2140
未结数:4 未结分:60
结贴率:94.44 % 结分率:97.27 %
值得尊敬
重复定义了呀
我想问问你的
this.name=n;
this.salary=s;
在哪定义的?