.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> OOPS >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

java program using vector class

Posted By:laptop charles       Posted Date: June 30, 2010    Points: 10    Category: OOPS    URL: http://www.dotnetspark.com  

Vector class.
 

Student data to manipulate by using vector class.
import java.io.*;
import java.util.*;

class stu
  {
        int n,rno,age;
      String name,address;
 
   void get()throws IOException
    {
     BufferedReader br=new Bufferedreader(new InputStreamReader(System.in));

     Vector v=new Vector();
      System.out.println("Enter how many student");
      n=Integer.parseInt(br.readLine());
  
     
   for(i=0;i<=n;i++)
   {

      System.out.println("Enter the roll no");
      rno=Integer.parseInt(br.readLine());
  
    /*  System.out.println("Enter the age");
      age=Integer.parseInt(br.readLine());

      System.out.println("Enter the name");
      name=Integer.parseInt(br.readLine());

      System.out.println("Enter the address");
      address=Integer.parseInt(br.readLine());*/
    


      
    v.addElement(new Integer(rno));
       
    }
   void disp()
    {
     for(i=0;i<=n;i++)
       System.out.println(i+"="+v.elementAt(i));     
    }
  }
}
public class main()
{
public static void main(String a[])throws IOException
{
stu h=new stu();
h.get();
h.disp();
} 
}
 

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend