class BusLine
{
public int n;
public String name;
String destination;
String startAddress;
BusLine(int n , String name,String destination,String startAddress)
{
this.n = n;
this.name = name;
this.destination = destination;
this.startAddress = startAddress;
}
void show()
{
Bus bus = new Bus();
bus.showB();
Line line = new Line();
line.showL();
line.showLB();
}
class Bus
{
int i;
String str;
Bus()
{
}

void receiverName()
{
str = name;
}
void showB()
{
System.out.println("banci " + i + ",name " +str);
}
} class Line 
{
int k;
String str1;
String str2;
Line()
{
}
void receiveStartAddress()
{

str1 = startAddress;
}
void showDestination()
{
str2 = destination;
}
void showL()
{
System.out.println("mudedi " + str2 + ",kaishidi " +str1);
}
void showLB()
{
Bus ob = new Bus();
ob.showB();
Line oa = new Line();
oa.showL();
}
}
}class BusLineDemo
{
public static void main(String args[])
{
BusLine a = new BusLine(11,"sanshui","guangzhou","sanshui");
a.show();

}
}为什么输入字符串的都是"NULL",输出整数的都是0

解决方案 »

  1.   

    class BusLine {
    public int n; public String name; String destination; String startAddress; BusLine(int n, String name, String destination, String startAddress) {
    this.n = n;
    this.name = name;
    this.destination = destination;
    this.startAddress = startAddress;
    } void show() {
    Bus bus = new Bus(n, name);
    bus.showB();
    Line line = new Line(destination, startAddress);
    line.showL();
    // line.showLB();
    } class Bus {
    int i; String str;
    //
    Bus(int i, String str) {
    this.i = i;
    this.str = str;
    }// void receiverName() {
    // str = name;
    // } void showB() {
    System.out.println("banci " + i + ",name " + str);
    }
    } class Line {
    // int k; String str1; String str2; Line(String str1, String str2) {
    this.str1 = str1;
    this.str2 = str2;
    }// void receiveStartAddress() {
    //
    // str1 = startAddress;
    // }// void showDestination() {
    // str2 = destination;
    // } void showL() {
    System.out.println("mudedi " + str2 + ",kaishidi " + str1);
    }// void showLB() {
    // Bus ob = new Bus();
    // ob.showB();
    // Line oa = new Line();
    // oa.showL();
    // }
    }
    }public class BusLineDemo {
    public static void main(String args[]) {
    BusLine a = new BusLine(11, "sanshui", "guangzhou", "sanshui");
    a.show(); }
    }楼主的代码有不少问题啊,我注释的地方你都没掉用啊,而且也不传值,怎么可以呢?