Social Icons

Saturday, 26 October 2013

Right Moving String in Java Applet

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*

<applet code=jitender width=400 height=400>
</applet>

*/


public class jitender extends Applet implements Runnable
{
Thread t=null;
boolean stopflag;
String msg,ch1;





  public void init()
  {
  setBackground(Color.cyan);
  setForeground(Color.red);
 }

 public void start()
  {
  msg="A simple jitender moving";
if(msg==null)
 {
  msg="message not found";
 }
msg=" "+msg;
 t=new Thread(this);
 stopflag=false;
  t.start();
}

public void run()
{
char ch;
String ch1;

 char p1[]=msg.toCharArray();
for( ; ;)
{
 try
   {
repaint();
Thread.sleep(250);

ch=p1[p1.length-1];

for(int i=p1.length-1;i>0;i--)
{
   p1[i]=p1[i-1];
 }
 p1[0]=ch;
ch1= String.valueOf(p1);
 msg=ch1;












   if(stopflag)
    {
    break;
     }


   }catch(InterruptedException e){}


}

}

public void stop()
{
   stopflag=true;
    t=null;
}

public void paint(Graphics g)
{
g.drawString(msg,50,30);
}

}

Sunday, 20 October 2013

dbms pl/sql curser

set serveroutput on;
DECLARE
   total_rows number(2);
BEGIN
   UPDATE e1111
   SET esalary = esalary + 500;
   IF sql%notfound THEN
      dbms_output.put_line('no customers selected');
   ELSIF sql%found THEN
      total_rows := sql%rowcount;
      dbms_output.put_line( total_rows || ' customers selected ');
   END IF;
END;

Sunday, 29 September 2013

Exception handling in java

class ex
{

 public static int quotient(int a,int b)
{

   if(b==0)
  {
  throw new ArithmeticException("divide by zero") ;
  }
 return a/b;


}


 public static void main(String args[])
 {
 int c;
 int a=5,b=0;
 

       
  try
  {
   c=quotient(a,b);
  System.out.println("the value of a/b is "+c);

  }



 catch(ArithmeticException e)
 {
  System.out.println("the b value can not be negative :");
 System.out.println(" :"+e.getMessage());
  System.out.println(" :"+e.toString());

  e.printStackTrace();
 }


     finally
       {
          System.out.println("hello finally is executed ");
 
              }            


}


}

Saturday, 28 September 2013

String character interchange in java

class str
{
public static void main(String args[])
{
String s="this is lecture class";
char temp;
String a[]=s.split(" ");

System.out.println("..........the String  are  ...... ");

for(int i=0;i<a.length-1;i++)
{
System.out.print("  "+a[i]);

}


System.out.println("  ");

for(int i=0;i<a.length-1;i++)
{
char p[]=a[i].toCharArray();
for(int j=0;j<p.length-1;j=j+2)
 {
  temp=p[j];
  p[j]=p[j+1];
  p[j+1]=temp;

}

 a[i]=new String(p);

}

System.out.println("..........the String after interchange of character ...... ");
for(int i=0;i<a.length-1;i++)
{
System.out.print("  "+a[i]);

}





}
}
 

Sample Text

Sample text

 
Just Programming Cse DriveReputation Management