Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: None  |  size: 1.97 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Unable to run Thread programme
  2. public class Myth extends Thread {
  3.   public void run() {
  4.     int val=65;
  5.     try {
  6.       for(int i=0;i<26;i++) {
  7.         System.out.println((char)val);
  8.         val++;
  9.         sleep(500);
  10.       }
  11.     }
  12.     catch(InterruptedException e) {
  13.       System.out.println(e);
  14.     }
  15.     // error pops up on this bracket saying class interface or enum expected.
  16.     // error in this line says-- illegal start of expression
  17.  
  18.     public static void main(String args[]) {
  19.       Myth obj=new Myth();
  20.       obj.start();
  21.     }
  22.   }
  23. }
  24.        
  25. public class Myth extends Thread{
  26.  public void run(){
  27.    int val=65;
  28.    try{
  29.        for(int i=0;i<26;i++){
  30.          System.out.println((char)val);
  31.          val++;
  32.          sleep(500);
  33.         }
  34.     }catch(InterruptedException e){
  35.        System.out.println(e);
  36.     }
  37.  }
  38.  
  39.  public static void main(String args[]){
  40.     Myth obj=new Myth();
  41.     obj.start();
  42.  }
  43. }
  44.        
  45. public class Myth extends Thread {
  46.  
  47. public void run() {
  48.  
  49.     int val = 65;
  50.     try {
  51.  
  52.         for (int i = 0; i < 26; i++) {
  53.             System.out.println((char) val);
  54.  
  55.             val++;
  56.  
  57.             sleep(500);
  58.  
  59.         }
  60.  
  61.     }
  62.  
  63.     catch (InterruptedException e) {
  64.         System.out.println(e);
  65.     }
  66. }
  67.  
  68. public static void main(String args[]) // error in this line says-- illegal
  69.                                         // start of expression
  70.  
  71. {
  72.     Myth obj = new Myth();
  73.     obj.start();
  74. }
  75. }
  76.        
  77. public class Myth extends Thread {
  78.     public void run(){
  79.         int val=65;
  80.         try {
  81.             for(int i=0;i<26;i++)
  82.             {
  83.                 System.out.println((char)val);
  84.                 val++;
  85.                 sleep(500);
  86.             }
  87.         }catch(InterruptedException e){
  88.             System.out.println(e);
  89.         }
  90.         // error pops up on this bracket saying class interface or enum expected.
  91.         // error in this line says-- illegal start of expression
  92.  
  93.     }
  94.     public static void main(String args[]){
  95.         Myth obj=new Myth();
  96.         obj.start();
  97.     }
  98. }