-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.java
More file actions
48 lines (36 loc) · 859 Bytes
/
class.java
File metadata and controls
48 lines (36 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.petehouston.tutorial.java;
import java.util.Arrays;
import java.util.Scanner;
import java.lang.Math;
import java.lang.String;
import java.util.Random;
public class HelloWorld {
public static void main(String[] args) {
Person p = new Person();
p.displayInfo();
p.name = "Meiirzhan";
p.age = 21;
p.displayInfo();
Person b = new Person("Tomas");
b.displayInfo();
Person d = new Person("Bob", 22);
d.displayInfo();
}
}
class Person{
String name;
int age;
Person(){
this("Gennady", 27);
}
Person(String name){
this(name, 18);
}
Person(String name, int age){
this.name = name;
this.age = age;
}
public void displayInfo(){
System.out.printf("Name: %s \t Age: %d\n", name, age);
}
}