- create a class called – Library
- Have a main method in it
- Inside main method object creation instance called book
- using book reference call method read(300);
- In read (int pages)method return pages
- store return value as pa
- print pa in main method
package terminaltask;
public class Library {
public static void main(String[] args) {
// TODO Auto-generated method stub
Enter fullscreen mode Exit fullscreen mode
Library book = new Library();
int pa = book.read(300);
System.out.println(pa);
}
public int read(int pages)
{
return pages;
}
}
out put –300
原文链接:Library Task
© 版权声明
THE END
暂无评论内容