Code.GeekInterview.com
 
 

Java Code Base

 
Code Samples Java
 

Creating objects in java


Code ResourceAuthor: Raju  

Difficulty Level:

Published: 2nd Sep 2007   Read: 5162 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. srinivasaraobora141328
2. iamdvr103090
3. venki_madesh35438
4. Raju20218
5. parmod kumar duhan16431
6. Kiran.jakkaraju15174
7. chowsys7800
8. ashish.cns6903
9. Venkateswara Rao6813
10. venkat_kiran5932

Active Coders

Refined Tags