这是一个程序:
class Book
{String title;
String author;
int numsold;
Book(){}
Book(String str1,String str2,int num)
{title=str1;
author=str2;
numsold=num;
}
void setBook(String str1,String str2,int num)
{title=str1;
author=str2;
numsold=num;
}
void printBook()
{System.out.println("书名:"+title);
System.out.println("作者:"+author);
System.out.println("月销售量:"+numsold);
}
}
public class TestBook
{
public static void main(String[] args)
{ Book book1=new Book();
book1.setBook("C#实用教程","吴军",700);
book1.printBook();
Book book2=new Book("C#语言基础教程","张威",600);
book2.printBook();
}
}
我想问的是,为什么删除了红色部分(其中一个方法)就不可以编译呢?