JAVA Program for using Wrapper Classes in JAVA

JAVA Program for using Wrapper Classes in JAVA:

// use of wrapper class method
import java.io.*;
class wraperclass
{
public static void main(String args[])
{
 int roll=0;
 Float marks = new Float(0);

 try
  {
  DataInputStream in = new DataInputStream(System.in);
  System.out.print("Enter Roll No : ");
  System.out.flush();
  String rn = in.readLine();
  roll = Integer.parseInt(rn);

  System.out.print("Enter Marks : ");
  System.out.flush();
  String m1 = in.readLine();
  marks = Float.valueOf(m1);
  }
  catch(IOException e)
   {
     System.exit(1);
     System.out.println("I/O Error");
   }
  System.out.println("Roll No. "+roll);
  System.out.println("Marks   "+marks);
  }
 }

OUTPUT:

Enter Roll No : 1
Enter Marks : 79

Roll No. 1
Marks   79.0

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.