Skip to content

Commit

Permalink
upload java programs
Browse files Browse the repository at this point in the history
  • Loading branch information
JaydipGabani committed Sep 9, 2019
0 parents commit 5caf496
Show file tree
Hide file tree
Showing 124 changed files with 2,776 additions and 0 deletions.
Binary file added A.class
Binary file not shown.
75 changes: 75 additions & 0 deletions A.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
class A implements Runnable
{
int n=-1;
int a[]=new int[15];
Thread t;
boolean v=false;
A(String s)
{
t=new Thread(this,s);
t.start();
}
public void pop()
{
for(;n!=-1;n--)
{
if(!v&&n==-1)
{
v=true;
notify();
}
if(n==-1)
{
try{
wait();
}catch(Exception e){System.out.println(e);}
notify();
}
System.out.println(a[n]);
}
}
public void push(int d)
{
for(n=0;n<15;)
{
if(v&&n==14)
{
v=false;
notify();
}
if(n==14)
{
try{
wait();
}catch(Exception e){System.out.println(e);}
}
n++;
a[n]=++d;
System.out.println(a[n]);
}
}
public void dis()
{
for(int i=0;i<a.length-1;i++)
{
System.out.println(a[i]);
}
}
public void run()
{
if(Thread.currentThread().getName().equals("SI"))
{
this.push(10);
}
else
this.pop();
}
public static void main(String s[])
{
new A("SD");
new A("SI");
//Thread t1=new Thread("SID");
//t.start();
//t1.start();
}
}
Binary file added Add.class
Binary file not shown.
15 changes: 15 additions & 0 deletions Add.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

abstract class box{
abstract void add();
}
class Add extends box{
void add()
{
System.out.println("yes");
}
public static void main(String s[])
{
Add c=new Add();
c.add();
}
}
Binary file added BIS.class
Binary file not shown.
15 changes: 15 additions & 0 deletions BIS.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import java.io.*;
class BIS
{
public static void main(String as[])throws Exception
{
byte s[]=new byte[10];
System.in.read(s);
BufferedInputStream br=new BufferedInputStream(new ByteArrayInputStream(s));
int c;
//s=br.read();

while((c=br.read())!=-1)
System.out.print((char)c);
}
}
Binary file added C.class
Binary file not shown.
49 changes: 49 additions & 0 deletions CardLayoutDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/* <applet code="CardLayoutDemo" width=300 height=100> </applet> */
public class CardLayoutDemo extends Applet implements ActionListener {
Checkbox Win98, winNT, solaris, mac;
Panel osCards;
CardLayout cardLO;
Button Win, Other;
public void init()
{
Win = new Button("Windows");
Other = new Button("Other");
add(Win);
add(Other);
cardLO = new CardLayout();
osCards = new Panel();
osCards.setLayout(cardLO); // set panel layout to card layout
Win98 = new Checkbox("Windows 98/XP", null, true);
winNT = new Checkbox("Windows NT/2000");
solaris = new Checkbox("Solaris");
mac = new Checkbox("MacOS");
winPan = new Panel();
winPan.add(Win98); winPan.add(winNT);
// Add other OS check boxes to a panel Panel
otherPan = new Panel();
otherPan.add(solaris);
otherPan.add(mac);
// add panels to card deck panel
osCards.add(winPan, "Windows");
osCards.add(otherPan, "Other");
// add cards to main applet panel
add(osCards);
// register to receive action events
Win.addActionListener(this);
Other.addActionListener(this);
// register mouse events addMouseListener(this);
}
// Cycle through panels. public void mousePressed(MouseEvent me) { cardLO.next(osCards); }
// Provide empty implementations for the other MouseListener methods. public void mouseClicked(MouseEvent me) { } public void mouseEntered(MouseEvent me) { } public void mouseExited(MouseEvent me) { } public void mouseReleased(MouseEvent me) { }
public void actionPerformed(ActionEvent ae) {
if(ae.getSource() == Win)
{
cardLO.show(osCards, "Windows");
}
else
{ cardLO.show(osCards, "Other"); }
}
}
Binary file added Db.class
Binary file not shown.
46 changes: 46 additions & 0 deletions Db.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import java.sql.*;
import java.util.*;
public class Db {
public static void main(String[] args)
{
try{
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:ucanaccess://C:/Users/Jaydeep/Documents/java2.accdb");
String q1="insert into t1 values(?,?)";
PreparedStatement pre=c.prepareStatement(q1);
Statement s=c.createStatement();
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
while(a!=0)
{
a=sc.nextInt();
pre.setInt(1,a);
pre.setInt(2,a);
int su=pre.executeUpdate();
}
/*String q="select * from t1";
s.execute(q);
ResultSet rs=s.getResultSet();
while(rs.next())
{
System.out.println(rs.getString(1)+" "+rs.getString(2));
}*/
String q3="create table t2(num number)";
//String q4="insert into t1 values(20,20)";
//String q5="alter table t1 add num number";
int i=s.executeUpdate(q3);
//i=s.executeUpdate(q4);
//i=s.executeUpdate(q5);
String q2="select Name from t1";
s.execute(q2);
ResultSet rs=s.getResultSet();
while(rs.next())
{
System.out.println(rs.getString(1));
}
}catch(Exception e)
{
System.out.println(e);
}
}
}
Binary file added FOD.class
Binary file not shown.
13 changes: 13 additions & 0 deletions FOD.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.io.*;
class FOD
{
public static void main(String as[])throws Exception
{
byte s[]=new byte[10];
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
//s=br.read();
System.in.read(s);
FileOutputStream f=new FileOutputStream("FOD.txt");
f.write(s,0,s.length);
}
}
Binary file added FOD.txt
Binary file not shown.
Binary file added FR.class
Binary file not shown.
13 changes: 13 additions & 0 deletions FR.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.io.*;
class FR
{
public static void main(String as[])throws Exception
{
//byte s[]=new byte[10];
FileReader f=new FileReader("FOD.txt");
BufferedReader br=new BufferedReader(f);
//s=br.read();
String s=br.readLine();
System.out.println(s);
}
}
Binary file added Game.class
Binary file not shown.
84 changes: 84 additions & 0 deletions Game.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import java.util.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code="Game" width=700 height=600></applet>*/
public class Game extends Applet implements Runnable,KeyListener
{
public static int i=0;
Thread t,p,o;
String n,m,k;
public void init()
{
setForeground(Color.red);
addKeyListener(this);
}
public void start()
{
//o=new Thread(this);
//o.setName("hihihi");
//k=o.getName();
p=new Thread(this);
p.setName("piller");
n=p.getName();
t=new Thread(this);
t.setName("bird");
m=t.getName();
t.start();
p.start();
}
public void keyPressed(KeyEvent ke)
{
repaint(100,100,200,200);
}
public void keyReleased(KeyEvent ke){}

public void run()
{
if(Thread.currentThread().getName().equals(n))
{
showStatus("hi htete");
try{
for(int j=0;j<100;j++)
{

Thread.sleep(20);
}
}
catch(Exception e)
{}
}
if(Thread.currentThread().getName().equals(m))
{
try{
for(;;)
{
showStatus("hi");
repaint();
Thread.sleep(20);
}
}catch(Exception e)
{}
}
}
public void paint(Graphics g)
{
i++;
if(i<500)
{
//showStatus("hi");
g.fillOval(10,i+10,20,20);
g.drawString(n,100,100);
g.drawString(m,110,110);
//this.run();
}
else
g.drawString("over",300,300);

}
public void keyTyped(KeyEvent ke)
{
char =ke.getKeyChar();

}
}
29 changes: 29 additions & 0 deletions Jdbc.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//package jdbc;
import java.sql.*;
public class Jdbc {
public static void main(String[] args) {
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
System.out.println("connection is established");
String str = " insert into student " +
"(id,name)"+
"(?,?)";
PreparedStatement p = con.prepareStatement(str);

//p.setInt(1,1);
p.setString(2,"abc");
p.executeUpdate(str);
System.out.println("insert sucess fully");



}
catch
(Exception e)
{
System.out.println("error");
}
}
}
Binary file added LY.class
Binary file not shown.
15 changes: 15 additions & 0 deletions LY.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import java.awt.*;
import java.applet.*;
/*<applet code="LY" width=400 height=400> </applet>*/
public class LY extends Applet
{
public void init()
{
setLayout(new GridLayout(0,1));
add(new Button("hi"));
setLayout(new GridLayout(2,1));
add(new Button("helo"));
add(new Button("helo"));
add(new Button("helo"));
}
}
13 changes: 13 additions & 0 deletions Odb.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package oracle;
import java.sql.*;
public class Odb {

public static void main(String[] args) throws Exception{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
Connection con =DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","","");
String s="create table id1 (Name varchar2)";
Statement st=con.createStatement();
st.executeUpdate(s);
}

}
Binary file added P.class
Binary file not shown.
Binary file added PC.class
Binary file not shown.
Binary file added Pb.class
Binary file not shown.
2 changes: 2 additions & 0 deletions Pb.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#TB
#Thu Nov 05 22:20:26 IST 2015
Loading

0 comments on commit 5caf496

Please sign in to comment.