Home >Java >javaTutorial >Library Task

Library Task

Linda Hamilton
Linda HamiltonOriginal
2025-01-03 15:59:41551browse

Library Task

  1. create a class called - Library
  2. Have a main method in it
  3. Inside main method object creation instance called book
  4. using book reference call method read(300);
  5. In read (int pages)method return pages
  6. store return value as pa
  7. print pa in main method

package terminaltask;

public class Library {

public static void main(String[] args) {
    // TODO Auto-generated method stub

Library book = new Library();
int pa = book.read(300);
System.out.println(pa);
}
public int read(int pages)
{
return pages;
}
}

out put --300

The above is the detailed content of Library Task. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn