import java.awt.*;
import java.awt.event.*;
class MyFrame extends Frame implements ActionListener
{
Label l1;
Button b1;
int i;
MyFrame()
{
super("Exapmle of ActionListener");
l1=new Label(" ");
b1=new Button("Click me");
b1.addActionListener(this);
i=0;
add(b1);
add(l1);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
setLayout(new FlowLayout());
setSize(500,500);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
i++;
l1.setText("Button Clicked: "+ Integer.toString(i));
}
}
public class MyActionListener
{
public static void main(String args[])
{
new MyFrame();
}
}
import java.awt.*;
import java.awt.event.*;
class MyFrame extends Frame implements ActionListener
{
Label l1;
Button b1;
int i;
MyFrame()
{
super("Exapmle of ActionListener");
l1=new Label(" ");
b1=new Button("Click me");
b1.addActionListener(this);
i=0;
add(b1);
add(l1);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
setLayout(new FlowLayout());
setSize(500,500);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
i++;
l1.setText("Button Clicked: "+ Integer.toString(i));
}
}
public class MyActionListener
{
public static void main(String args[])
{
new MyFrame();
}
}
import java.util.*;
class Fibonacci
{
int n;
Fibonacci()
{
Scanner s=new Scanner(System.in);
System.out.print("Enter the number of terms: ");
n=s.nextInt();
}
void show()
{
int f=0,s=1,t;
System.out.print(f+","+s);
for(int i=3;i<=n;i++)
{
t=f+s;
System.out.print(","+t);
f=s;
s=t;
}
}
}
class TestFibo
{
public static void main(String args[])
{
Fibonacci f= new Fibonacci();
f.show();
}
}
import java.util.*;
import java.io.*;
class MyFile
{
File f1;
MyFile()
{
Scanner s = new Scanner(System.in);
System.out.print("Enter the path of file: ");
String path= s.nextLine();
System.out.print("Enter the name of file: ");
String name= s.nextLine();
f1=new File(path, name);
}
void check()
{
try
{
if(f1.isFile() && f1.exists())
{
FileInputStream fobj = new FileInputStream(f1);
int i=fobj.read();
while(i!=-1)
{
if(Character.isDigit((char)i))
{
System.out.println("Character is digit");
}
else if (Character.isSpace((char)i))
{
System.out.println("Character is Space");
}
else
{
if(Character.isUpperCase((char)i))
System.out.println(Character.toLowerCase((char)i));
else
System.out.println(Character.toUpperCase((char)i));
}
i=fobj.read();
}
}
else
{
System.out.println("File doesn't exist");
}
}
catch(Exception e)
{
System.out.print(e);
}
}
}
class slip1
{
public static void main(String args[])
{
MyFile obj = new MyFile();
obj.check();
}
}