A Java class is a group of Java objects all of which have the same or similar properties in common. Classes are logical entities and can never be physical. In a class you may find:
● Fields
● Methods
● Constructors
● Blocks
● Nested classes and an interface [Read more…] about Java Class Example Code
Find Largest and Smallest Number in an Array Using Java Example
In the Following example LargestandSmallestnumber shows how to Find Largest and Smallest Number in an Array Using Java Example [Read more…] about Find Largest and Smallest Number in an Array Using Java Example
Changing the Cursor in Java Example
In the Following example ChangeCursor shows how to Changing the Cursor in Java with setCursor() method defined in the Component class. setCursor method is used to changes the cursor icon when the cursor goes upon the particular component. and the getPredefinedCursor() method returns the cursor object to be specified in the cursor block. Changing Cursor means showing cursor in many different shapes when the cursor goes upon the particular component.
Here is the java code for the program ChangeCursor :
Create a Simple Window Using JFrame – Java
The basic component that require whenever we implement a visual interface to rid Swing is the JFrame (top-level container) class. This class encapsulates a classic window any operating system with graphical environment (Windows, OS X, Linux etc.)
We have said that this class is in the javax.swing package and as we usually use several classes to import this package then use the syntax: import javax.swing.*;
1. In the beginning of the program, the javax.swing package is imported.
2. Next, JavaSimpleFrame class is declared. An object of JFrame class is created using the statement.
JFrame frame =new JFrame ();
It creates a container called frame that defines a rectangular window with a specified string displayed on the title bar.
3. The size of the window is specified by using the statement.
frame.setSize (350, 250);
The general form of setSize() method to set the size of the window is:
void setSize (int width, int height)
where,
width is the width of the window
height is the height of the window
4. The statement used for terminating the program when the window is closed is:
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
When the above statement is executed, the entire application terminates with the closing of window.
The general form of setDefaultCloseOperation() is
void setDefaultCloseOperation (int w)
where, w specifies the action to be performed on the window when it is closed. It has several options which are as follows
JFrame.DISPOSE_ON_CLOSE
JFrame.HIDE_ON_CLOSE
JFrame.DO_NOTHING_ON_CLOSE
By default, when the top-level window is closed, the application is not terminated. It simply removes the window from the screen.
5. The statement to make the window visible is
frame.setVisible(true);
The setVisible () method is inherited from the AWT Component class. If it is set to true, the window will be displayed, otherwise not. By default, a JFrame is invisible.
import javax.swing.*;
class JavaSimpleFrame
{
public static void main(String[] args)
{
//thread safe app
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {new SimpleFrame();}});
}
}
class SimpleFrame extends JFrame
{
private static final int WIDTH = 350;
private static final int HEIGHT = 250;
public SimpleFrame() {
//make sure we have nice Java's look and feel window
setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame();
frame.setTitle("Simple Frame");
frame.setSize(WIDTH, HEIGHT);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
A Simple Window Using Frame Example in Java
Java Program to Find Odd or Even Numbers | Java Examples
In the Following example OddorEvenNumbers use mod operator to check if the number is even or odd. If the number divided by 2 and the reminder is 0 then number is even, otherwise the number is odd.
Here is the java code for the program OddorEvenNumbers :
[Read more…] about Java Program to Find Odd or Even Numbers | Java Examples
Calculate Rectangle Area Using Java Example
In the Following example AreaofRectangleExample shows how to Calculate Area of Rectangle is length * width.
[Read more…] about Calculate Rectangle Area Using Java Example
Calculate Circle Perimeter Using Java Example
In the Following example PerimeterofCircleExample shows how to Calculate Perimeter of Circle using 2*pi*r. where r is a radius of a circle.
[Read more…] about Calculate Circle Perimeter Using Java Example
Area of Circle Example in Java
In the Following example AreaofCircleExample shows how to Calculate Area of Circle using pi*r*r. where r is a radius of a circle.
Draw 3D Rectangles Java Example
In the Following Draw3DRectExample shows how to Draw 3DRect or Fill 3DRect using draw3DRect,fill3DRect method of Graphics class. The Syntax for draw3DRect(int x_coordinates,int y_coordinates, int width, int height, boolean raised) and The Syntax for fill3DRect(int x_coordinates,int y_coordinates, int width, int height, boolean raised)
Here is the java code for the program Draw3DRectExample :.
Draw Smiley in Applet Example
Following example SmileExample shows how to Smily face using an Applet window with drawArc,fillArc, drawLine,fillOval drawOval method of Graphics class.
Here is the java code for the program SmileExample :.
GetDocumentBase and getCodeBase Example
In most of the applets, it is required to load text and images explicitly. Java enables loading data from two directories. The first one is the directory which contains the HTML file that started the applet (known as the document base). The other one is the directory from which the class file of the applet is loaded (known as the code base). These directories can be obtained as URL objects by using getDocumentBase ()and getCodeBase ()methods respectively. You can concatenate these URL objects with the string representing the name of the file that is to be loaded.
Here is the java code for the program GetDocumentBase and getCodeBase Example :.*/
How to Set the Dimension of the Applet
Eample AppletDimension print center aligned text “Hello Java” This Java example ‘How to Set the Dimension of the Applet’ shows how to print a string in center of an applet screen window using the Dimension class.
In the Following example AppletDimension shows How to Set the Dimension of the Applet using getSize(),getFontMetrics() method. The Syntax for getting X coordinates are
x_coordinates = dimension.width/2 – fontmetrics.stringWidth(str)/2 and The Syntax for getting Y coordinates are y_coordinates = dimension.height/2 – fontmetrics.getHeight()/2;
Here is the java code for the program AppletDimension Example :.
Fill Screen With Pixel in Applet windows Example
In the Following example PixelsApplet shows how to Fill Screen With Pixel in Applet windows Example and set color of an Applet window using setColor(),Random(), method of Graphics class for color the screen. Following example demonstrates how to Random setcolor with RGB values, for this you can use a Color object.
Here is the java code for the program PixelsApplet :
[Read more…] about Fill Screen With Pixel in Applet windows Example
Draw Dashed Stroke Polygon Applet Window Example
In the Following example DashedStrokeApplet shows how to Draw Dashed Stroke Polygon Applet Window Example using Graphics2D class and setPaint(),setStroke(),BasicStroke() method of Graphics class. The Syntax for drawPolygon(int[] xPoints, int[] yPoints, int numPoint); and The Syntax for BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase) ; setStroke is an inteface defined in the java.awt package.
Here is the java code for the program DashedStrokeApplet:.
import java.applet.Applet;
import java.awt.*;
import java.awt.BasicStroke;
import java.awt.event.*;
public class DashedStrokeApplet extends Applet
{
public static void main(String[] args)
{
DashedStrokeApplet DashedStroke = new DashedStrokeApplet();
Frame StrokeApplet = new Frame("Draw Dashed Stroke Polygon Applet Window Example");
StrokeApplet.add(DashedStroke);
StrokeApplet.setSize(350, 250);
StrokeApplet.setVisible(true);
StrokeApplet.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0); } });
}
public void paint (Graphics g)
{
g.setColor(Color.darkGray);
g.setFont(new Font("Arial",Font.BOLD,14));
g.drawString("Stroke Polygon Applet Window Example", 10, 20);
g.setFont(new Font("Arial",Font.BOLD,10));
g.drawString("http://ecomputernotes.com", 200, 205);
Graphics2D Gr2D = (Graphics2D) g;
// Array of a dash pattern 40-pixel line, 10-pixel gap, 20-pixel line, 10-pixel gap
float [] d1 = {40, 10, 20, 10};
int[] X_polygon = {70, 210, 170, 210, 70, 110};
int[] Y_polygon = {50,50, 120, 190, 190, 120};
Gr2D.setPaint(Color.green);
//The Syntax for BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase) ;
BasicStroke BasicS1 = new BasicStroke (9, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
Gr2D.setStroke (BasicS1);
Gr2D.drawPolygon (X_polygon, Y_polygon, 6);
Gr2D.setPaint(Color.blue);
BasicStroke BasicS2 = new BasicStroke (7, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0F, d1, 0.F);
Gr2D.setStroke (BasicS2);
//The Syntax for drawPolygon(int[] xPoints, int[] yPoints, int numPoint);
Gr2D.drawPolygon (X_polygon, Y_polygon, 6);
}
}
BasicStroke Example – Draw Dashed Line in Applet Window in Java
In the Following example DashedLinesApplet shows with Basic Stroke how to Draw Dashed Line in Applet and set foreground color of an Applet window using Graphics2D class and setPaint(),setStroke(), BasicStroke() method of Graphics class. The Syntax for BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase) ; setStroke is an inteface defined in the java.awt package.
import java.awt.BasicStroke;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class DashedLinesApplet extends Applet
{
public static void main(String[] args)
{
DashedLinesApplet DashesLines = new DashedLinesApplet();
Frame DLApplet = new Frame("Draw Dashed Line in Applet Window Example");
DLApplet.add(DashesLines);
DLApplet.setSize(350, 250);
DLApplet.setVisible(true);
DLApplet.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0); }
});
}
public void paint(Graphics g)
{
g.setColor(Color.darkGray);
g.setFont(new Font("Arial",Font.BOLD,14));
g.drawString("Draw Dashed Line in Applet Window Example", 10, 40);
g.setFont(new Font("Arial",Font.BOLD,10));
g.drawString("http://ecomputernotes.com", 200, 205);
Graphics2D Gr2D = (Graphics2D) g;
// Array of a dash pattern 40-pixel line, 10-pixel gap, 20-pixel line, 10-pixel gap
float[] d1 = { 40, 10, 20, 10 };
//The Syntax for BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase) ;
BasicStroke BasicS = new BasicStroke(1, BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL, 10, d1,0);
Gr2D.setStroke(BasicS);
Gr2D.setPaint(Color.red);
Gr2D.drawLine(60, 80, 250, 80);
BasicStroke BasicS1 = new BasicStroke(1, BasicStroke.CAP_ROUND,BasicStroke.JOIN_MITER, 10, d1,0);
Gr2D.setStroke(BasicS1);
Gr2D.setPaint(Color.green);
Gr2D.drawLine(60, 100, 250, 100);
BasicStroke BasicS2 = new BasicStroke(1, BasicStroke.CAP_SQUARE,BasicStroke.JOIN_ROUND, 10, d1,0);
Gr2D.setStroke(BasicS2);
Gr2D.setPaint(Color.blue);
Gr2D.drawLine(60, 120, 250, 120);
}
}
Draw Image in Applet Window Java Example
In the Following example Draw Image in Applet shows how to Draw Image on Applet window using getDefaultToolkit(),drawImage(), method of Graphics class. To draw the images, we use java.awt.Graphics package comes with a drawImage() of Graphics class. The syntax for drawImage(image, int x, int y);
Here is the java code for the program Draw Image in Applet:.
Drawing Polygons in Applet Window Example
A polygon is a closed geometrical figure which can have any number of sides. A polygon can be drawn by using the drawPolygon () method. This method takes three parameters.
The general form of the drawPolygon () method is:
void drawPolygon (int a [], int b [], int n)
where,
a [ ] is the array of integers having x-coordinates
b [ ] is the array of integers having y-coordinates
n is the total number of coordinate points required to draw a polygon.
Here is the java code for the program AppletDrawPolygon :.
[Read more…] about Drawing Polygons in Applet Window Example
Draw Rounded Corner Rectangle & Square in Applet Window Example
In the Following example AppletDrawRect shows how to Draw Rectangle or Fill Rectangle and draw filled rounded corner rectangle or set foreground color of an Applet window using drawRect,fillRect, drawRoundRect, fillRoundRect method of Graphics class. The Syntax for The Syntax for drawRect(int xTopLeft, int yTopLeft, int width, int height); and The Syntax for fillRect(int xTopLeft, int yTopLeft, int width, int height); and The Syntax for round cornered square drawRoundRect(int xTopLeft, int yTopLeft, int width, int height, int arcWidth, int arcHeight), and The Syntax for fillRoundRect(int xTopLeft, int yTopLeft, int width, int height, int arcWidth, int arcHeight)
Following example demonstrates how to set color’s with RGB values, for this you can use a Color object. For AppletDrawRect example, an RGB(R for Red, G for Green and B
for Blue) value for dark blue Color is 0 red, 0 is green, and 200 is blue. Following example AppletDrawRect shows of an applet that displays dark blue Rectangle .
Here is the java code for the program AppletDrawRect :.
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class AppletDrawRect extends Applet
{
public static void main(String[] args)
{
Frame RectApplet = new Frame("Draw Rectangle in Applet Window Example");
RectApplet.setSize(350, 250);
Applet AppletDrawRect = new AppletDrawRect();
RectApplet.add(AppletDrawRect);
RectApplet.setVisible(true);
RectApplet.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);} });
}
public void paint(Graphics g)
{
g.setColor(Color.darkGray);
g.setFont(new Font("Arial",Font.BOLD,14));
g.drawString("Draw Rounded Corner Rectangle", 50, 40);
g.setFont(new Font("Arial",Font.BOLD,10));
g.drawString("http://ecomputernotes.com", 200, 205);
//set color to Blue
Color darkblue = new Color(0, 0, 200);
g.setColor(darkblue);
//this will draw a Rectangle of width 50 & height 70 at (10,50)
//The Syntax for drawRect(int xTopLeft, int yTopLeft, int width, int height);
g.drawRect(10,50,50,70);
//this will Fill Rectangle of width 50 & height 70 at (70,50)
//The Syntax for fillRect(int xTopLeft, int yTopLeft, int width, int height);
g.fillRect(70,50,50,70);
// If you speficy same width 50 and height 50, the drawRect method will draw a square!
//The Syntax for square drawRect(int xTopLeft, int yTopLeft, int width, int height);
g.drawRect(130,50,50,50);
//this will draw a round cornered rectangle of width 50 & height 70 at (10,130)
//The Syntax for round cornered square drawRoundRect(int xTopLeft, int yTopLeft, int width, int height, int arcWidth, int arcHeight)
g.drawRoundRect(10,130,50,70,20,20);
//draw filled rounded corner rectangle
//The Syntax for fillRoundRect(int xTopLeft, int yTopLeft, int width, int height, int arcWidth, int arcHeight)
g.fillRoundRect(70,130,50,70,20,20);
//this will draw a round cornered square
//The Syntax for round cornered square drawRoundRect(int xTopLeft, int yTopLeft, int width, int height, int arcWidth, int arcHeight)
g.drawRoundRect(130,130,50,50,10,10);
}
}
Draw Oval in Applet Window Example
DrawOval The method can be used to draw ellipses or circles of drawRect manner analogous to the method, ie by defining the location of the vertex upper left (x, y) of the rectangle which fits the definition of ellipse and its width width and height height, as indicated:
In the Following example AppletDrawOval shows how to Draw Oval or Fill Oval and set foreground color of an Applet window using drawOval , fillOval, method of Graphics class.
The Syntax for drawOval(int xTopLeft, int yTopLeft, int width, int height); and The Syntax for fillOval(int xTopLeft, int yTopLeft, int width, int height);
Following example demonstrates how to set color’s with RGB values, for this you can use a Color object. For AppletDrawOval example, an RGB(R for Red, G for Green and B
for Blue) value for dark red Color is 235 red, 50 is green, and 50 is blue. Following example AppletDrawOval shows of an applet that displays dark red Oval .
Here is the java code for the program AppletDrawOval :.
How to Draw a Line In Java with drawline() method.
The simplest shape that you can draw with Graphics class is a line. The drawLine() method of the Graphics class is used to draw a line with current color between two points. This method takes the following form
void drawLine(int x1, int y1, int x2, int y2)
The DrawLine method can be used for drawing straight lines between two points (x1, y1) and (x2, y2) data. Following example DrawLine shows how to Draw a Line on Applet window using drawLine method of Graphics class.
To draw a point at (x, y) we could write: g.drawLine (x, y, x, y); The point thus drawn using the current color of the graphics context, which can be changed using the setColor method.
For example, the statement g.drawLine (20, 100, 90, 100) will draw a straight line from the coordinate point (20, 100) to (90, 100) as shown in Figure
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class DrawLine extends Applet
{
public static void main(String[] args)
{
Frame drawLineApplet = new Frame("Draw Line in Applet Window Example");
drawLineApplet.setSize(350, 250);
Applet DrawLine = new DrawLine();
drawLineApplet.add(DrawLine);
drawLineApplet.setVisible(true);
drawLineApplet.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0); }
});
}
public void paint(Graphics g)
{
// Now we tell g to change the font
g.setFont(new Font("Arial",Font.BOLD,14));
//Syntax: drawString(String str, int xBaselineLeft, int yBaselineLeft);
g.drawString("This is Draw Line Example", 100, 70);
// draws a Line
g.setColor(Color.blue); // Now we tell g to change the color
//Syntax For:- drawLine(int x1, int y1, int x2, int y2);
g.drawLine(90, 135, 90, 180);
g.setColor(Color.green); // Now we tell g to change the color
g.drawLine(0, 0, 100, 100);
}
}
Draw Arc in Applet Window Example
An arc can be drawn using the drawArc () method. This method takes six arguments in which the first four are same as the arguments of the drawoval () method and the next two represents the starting angle of the arc and the sweep angle around the arc, respectively.
The general form of the drawArc () method is:
void drawArc (int a1, int b1, int w, int h, int strt_angle, int sweep_angle)
where,
a1, b1 is the coordinate of the top left comer of the bounding rectangle
w is the width of the bounding rectangle
h is the height of the bounding rectangle
strt _angle is the starting angle of the arc (in degrees)
sweep_angle is the number of degrees (angular distance) around the arc (in degrees)
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class DrawArc extends Applet {
public static void main(String[] args) {
Frame DrawArcApplet = new Frame("Draw Arc in Applet Window Example");
DrawArcApplet.setSize(350, 250);
Applet DrawArc = new DrawArc();
DrawArcApplet.add(DrawArc);
DrawArcApplet.setVisible(true);
DrawArcApplet.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public void paint(Graphics g) {
// draws String
g.drawString("This is Arc Shapes Example", 100, 70);
// Draws an Arc Shape
g.drawArc(30,5, 200, 200, 0, -90); //Syntax For:- drawArc(int xTopLeft, int yTopLeft, int width, int height, int startAngle, int arcAngle);
// Fill an Arc Shape
g.fillArc(30, 5, 200, 200, 0, -90); //Syntax For:- fillArc(int xTopLeft, int yTopLeft, int width, int height, int startAngle, int arcAngle);
}
}
How to Change Background And Foreground Color of Applet in Java
The Color class provides various methods to use any color you want in display. It defines various color constants which can be directly used only by specifying the color of your choice. In addition, the Color class allows creation of millions of colors. The Color class contains three primitive colors namely, red, blue and green and all other colors are a combination of these three colors. One of the constructors that is used to create color of your choice is
Color (int red, int green, int blue)
where,
red, green, blue can take any value between 0 and 255.
Setting Background and Foreground Color
To set the color of the background of an applet window, setBackground () method is used.
The general form of the setBackground () method is
void setBackground(mycolor)
Similarly, to set the foreground color to a specific color, that is, the color of text,
setForeground () method is used.
The general form of the setForeground () method is
void setForeground(mycolor)
where,
mycolor is one of the color constants or the new color created by the user
The list of color constants is given below:
• Color.red
• Color.orange
• Color.gray
• Color.darkGray
• Color.lightGray
• Color.cyan
• Color.pink
• Color.white
• Color.blue
• Color.green
• Color.black
• Color.yellow
import java.applet.Applet;
import java.awt.*; //Color and Graphics belongs to java.awt,
import java.awt.event.*;
public class ColorApplet extends Applet
{
public static void main(String[] args)
{
Frame ForegroundBackgroundColor = new Frame("Change Background and Foreground Color of Applet");
ForegroundBackgroundColor.setSize(420, 180);
Applet ColorApplet = new ColorApplet();
ForegroundBackgroundColor.add(ColorApplet);
ForegroundBackgroundColor.setVisible(true);
ForegroundBackgroundColor.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0); }
});
}
public void paint(Graphics g)
{
Color c = getForeground();
setBackground(Color.yellow); /*There are many predefined colors, or you can create your own predefined colors to Change are
black,blue,cyan,darkGray,gray,green,lightGray,magenta,orange,pink,red,white,yellow */
setForeground(Color.red); /*There are many predefined colors, or you can create your own predefined colors to Change are
black,blue,cyan,darkGray,gray,green,lightGray,magenta,orange,pink,red,white,yellow */
g.drawString("Foreground color set to red", 100, 50); // Drawing texts on the graphics screen:
g.drawString(c.toString(), 100, 80); /*The drawString() method, takes parameters as instance of String containing where the text to be drawn, and two integer values specifying
the coordinates where the text should place.*/
g.drawString("Change Background and Foreground Color of Applet", 50, 100);
}
}
Java Applet – How to Shapes Drawn in applet.
In this shapeDrawingApplet program we see how to draw the different shapes like line, circle and rectangle.
GraphicsObject.drawLine() :
The drawLine() method is used in this program to draw the line. Here is the syntax:
GraphicsObject.drawLine(int x_coordinate, int y_coordinate, int x1_coordinate, int y1_coordinate);
GraphicsObject.drawString() :
The drawSring() method is used in this program to draw string . Here is the syntax :
GraphicsObject.drawString(String str, int x_coordinate, int y_coordinate);
GraphicsObject.drawOval() :
The drawOval() method is used to draws the circle. Here is the syntax :
GraphicsObject.drawOval(int x_coordinate, int y_coordinate, int width, int height);
GraphicsObject.drawRect() :
The drawRect() method is used to draws the rectangle. Here is the syntax :
GraphicsObject.drawRect(int x_coordinate, int y_coordinate, int Wdth, int height);
Here is the shapeDrawingApplet program java code :.
[Read more…] about Java Applet – How to Shapes Drawn in applet.
How to Show Status Message in java Applet Example?
In this showStatusMessage example You can see an message is shown on the Status bar of applet.
/* Show status message in an Applet window code using void showStatus(String Message) method of an applet class. */
[Read more…] about How to Show Status Message in java Applet Example?
How to run the applet from command line?
In this CommandLineApplet example You can see an applet program run from command Line without using any web browser. [Read more…] about How to run the applet from command line?
Java Applet Hello World Examples
An applet is a class file that is specially written to display graphics in a web browser. Applets are embedded in web pages using the HTML tag <Applet>. Java applets are downloaded automatically and run by the web browser. Any web-browser that supports Java, such as Applet Viewer, can be used to transport applets to the Internet. An applet can perform many functions such as graphics, play sound, animation, arithmetic operations, play games etc. [Read more…] about Java Applet Hello World Examples
Difference Between JRE ,JDK and JVM
Java Virtual Machine (JVM)
Write a java program changing the case of a string(Lower case)
import java. util. *;
class InputDemo
{
public static void main(String args[])
{
String l;
Scanner s=new Scanner(System.in);
System.out.println("Enter the string");
l=s.next( );
String res=l.toLowerCase( );
System. out. println( res);
}}
Write a program to print the name and roll no of the student using static members
import java.lang. *;
class InputDemo
{
static int rollno=1553;
static String name ="Xavier";
static void display( )
{
System.out.println("Rollno: " + rollno);
System.out.println("Name : "+ name);
}
public static void main(String args[] )
{
display ( );
}
}