HKProgrammingWorld

HKProgrammingWorld

Share

Hari Krishna, Naresh i Technologies for sharing Java and its related Technologies knowledge. Through this page we will share the activities we do in hkprogrammingworld.in website. It is an online educational portal for Java Beginners to become Java experts.Through this website you can learn Java easily.

Photos from HKProgrammingWorld's post 27/05/2022
Photos from HKProgrammingWorld's post 18/03/2022

Storing primitive values, array object and class object by using another class and its object memory diagram
==========================================
class Example {
int i1 = 5;
double d1 = 6.7;
char ch = 'a';
long[] la = {8, 9};
String s = "Hari";
}

class Sample {
float f1 = 4.5F;
boolean bo = true;
char[] ch = {'p', 'q'};
Example e1 = new Example();
}

class Test11_ClassItsAdv{
public static void main(String[] args) {

//Adv #1: We can store multiple values of different type as one group with name
Sample s1 = new Sample();

System.out.println(s1);
System.out.println(s1.f1);
System.out.println(s1.bo);
System.out.println(s1.ch);
System.out.println(s1.e1);
System.out.println(s1.e1.i1);
System.out.println(s1.e1.d1);
System.out.println(s1.e1.ch);
System.out.println(s1.e1.la);
System.out.println(s1.e1.la[0]);
System.out.println(s1.e1.la[1]);
System.out.println(s1.e1.s);
System.out.println();

//Adv #2: We can pass multiple values of different type as arguemtn with parameter name
m1(s1);
System.out.println();

//Adv #3: We can return multiple values of different type from a method with single return type
Sample s2 = m2();
System.out.println(s2);
System.out.println(s2.f1);
System.out.println(s2.bo);
System.out.println(s2.ch);
System.out.println(s2.e1);
System.out.println(s2.e1.i1);
System.out.println(s2.e1.d1);
System.out.println(s2.e1.ch);
System.out.println(s2.e1.la);
System.out.println(s2.e1.la[0]);
System.out.println(s2.e1.la[1]);
System.out.println(s2.e1.s);
System.out.println();
}

static void m1(Sample s){
System.out.println(s);
System.out.println(s.f1);
System.out.println(s.bo);
System.out.println(s.ch);
System.out.println(s.e1);
System.out.println(s.e1.i1);
System.out.println(s.e1.d1);
System.out.println(s.e1.ch);
System.out.println(s.e1.la);
System.out.println(s.e1.la[0]);
System.out.println(s.e1.la[1]);
System.out.println(s.e1.s);
}

//Adv #3: We can return multiple values of different type from a method with single return type
static Sample m2(){
return new Sample();
}
}

Want your business to be the top-listed Computer & Electronics Service in Hyderabad?
Click here to claim your Sponsored Listing.

Telephone

Address


Ameerpet
Hyderabad
500016