Code.GeekInterview.com
 
 

Java Code Base

 
Code Samples Java
 

Create a New Class


Code ResourceAuthor: rakesh  

Difficulty Level:

Published: 27th Aug 2007   Read: 4091 times  

Filed in: Java
Add Comment


 

 

Sponsored Links


 

 

Creating new class for package. The code provided here below shows how to create the main class and then shows how to create objects for the class.

 


Sample Code
  1.  
  2. class Vehicle                    class and class name
  3. {
  4.            int wheels,weight;
  5.            Sting color;
  6.            void move()            move is the method
  7.            {
  8.                        System.out.println("moving");
  9.                          
  10.            }
  11.            void stop()            stop is the second method
  12.            {
  13.                        System.out.println("stop");
  14.            }
  15. }
  16. class CreateVehicles
  17. {
  18.             public static void main(String args[])
  19.             {
  20.              Vehicle bicycle=new Vehicle();
  21.              Vehicle bike=new Vehicle();
  22.  
  23.              bicycle.move();
  24.              bicycle.stop();
  25.             }
  26. }
  27.  
Copyright GeekInterview.com


Next Article: Send email using Gmail SMTPS


 

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