Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
javaClassAr2
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' ////////////////////////////////////////////////////////////////////////////////javaClassAr2:Creating and Initializing an array of objects in Java class //this code is created by Rezaul Hoque on September 20,2022; //contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; ////////////////////////////////////////////////////////////////////////////// import java.util.*; import java.lang.*; class Demo{ String name; int id; int phone; public Demo(){ } public Demo(String n,int a,int c){ this.name=n; this.id=a; this.phone=c; } public String getN(){return name;} public int getID(){return id;} public int getP(){return phone;} } class Rextester { public static void main(String args[]) { Demo[] e=new Demo[]{ new Demo("XYZ",89,12345), new Demo("FGH",90,54321), new Demo ("QWE",21,45678) }; System.out.println("ID\tName\tPhone"); for (int i=0;i<3;i++) System.out.printf("%d\t%s\t%d\n",e[i].getID(),e[i].getN(),e[i].getP()); } }
run
|
edit
|
history
|
help
0
Hello world
Scope
Javaprog.java
Hanna Rextster.com
Opr
bit left 2
getListVehicules
Inheritance
Coding Challenge - 04 (Perfect numbers)
Kochergina_1