这是我的第一堂课:
public class Fraction
{
int Numerator;
int Denominator;
/**
* Constructor for objects of class Fraction
*/
public Fraction()
{
// initialise instance variables
Numerator=0;
Denominator=0;
}
public Fraction(int StartNumerator , int StartDenominator)
{
StartNumerator = Numerator;
StartDenominator = Denominator;
}
public String toString()
{
String FractionOne = Numerator + "/" + Denominator;
String FractionTwo = Numerator + "/" + Denominator;
return FractionOne;
return FractionTwo;
}
}
这是我的第二堂课:
public class TestFraction
{
public static void main (String [] args)
{
Fraction FractionOne = new Fraction(1 , 4);
Fraction FractionTwo = new Fraction(2 , 3);
System.out.println(FractionOne);
System.out.println(FractionTwo);
}
}
当我编译时,我得到一个错误:return FractionTwo; 作为一个无法到达的声明
请帮助我理解我做错了什么。