Code.GeekInterview.com
 
 

Java Code Base

 
Code Samples Java
 

Creating objects in java


Code ResourceAuthor: Raju  

Difficulty Level:

Published: 2nd Sep 2007   Read: 4913 times  

Filed in: Java
Add Comment


 

 

Sponsored Links


 

 

This program comprises of creating two objects for our own class shown below. Here A is the main class a1,a2 are the objects created for the class.

 


Sample Code
  1.  
  2. class A
  3. {      
  4.         int i=1;
  5.         void show()
  6.         {
  7.                 System.out.println("i="+i);
  8.         }
  9. }
  10. class Display
  11. {
  12.         public static void main(String args[])
  13.         {
  14.                 A a1=new A();
  15.                 a1.show();
  16.  
  17.                 A a2=new A();
  18.                 a2.show();
  19.         }
  20. }
  21.  
Copyright GeekInterview.com


Next Article: Create a New Class


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Popular Coders

# Coder NameHits
1. srinivasaraobora130748
2. iamdvr97694
3. venki_madesh35135
4. Raju18488
5. parmod kumar duhan15757
6. Kiran.jakkaraju14058
7. chowsys7457
8. Venkateswara Rao6477
9. ashish.cns6349
10. Vamshidhar Matam5428

Active Coders

Refined Tags