Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.sample;
- import static java.lang.System.out;
- class Boy {
- public Boy() {
- out.println("Boy constructor one");
- }
- public Boy(int n) {
- out.println("Boy constructor two, n = " + n);
- }
- public void hello(String name) {
- out.println(name + " say hello method.");
- }
- }
- public class JavaProject21 {
- public static void main(String[] args) {
- Boy boy1 = new Boy();
- boy1.hello("boy1");
- out.print("\n");
- Boy boy2 = new Boy(16);
- boy2.hello("boy2");
- out.print("\n");
- Boy boy3 = null;
- boy3 = new Boy(20);
- boy3.hello("boy3");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement