- Create a class called Bank.
- Have main method in it. public static void main(String[] args)
- Create an object called 'bank'.
Bank bank = new Bank()
- Using 'bank' object, call deposit(1000)
bank.deposit(1000);
- Create a method deposit(int amount)
- return 1000 - 500 from this method.
- Store the returned value as amount.
- Print the amount
package terminaltask;
public class Bank {
public static void main(String[] args)
{
// TODO Auto-generated method stub
Bank indian = new Bank();
int amount = indian.deposit(1000);
System.out.println(amount);
}
public int deposit (int amount)
{
return 1000-500;
}
out put -- 500
}
The above is the detailed content of Bank 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