SHARE
TWEET

Untitled

a guest Sep 22nd, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package tirsdagklasser;
  7.  
  8. import java.util.logging.Level;
  9. import java.util.logging.Logger;
  10.  
  11. /**
  12.  *
  13.  * @author nbh
  14.  */
  15. public class TirsdagKlasser {
  16.  
  17.     /**
  18.      * @param args the command line arguments
  19.      */
  20.     public static void main(String[] args) {
  21.         // TODO code application logic here
  22.        
  23.        
  24.         IfKlasse ifKlasse = new IfKlasse() {
  25.             @Override
  26.             public void hej() {
  27.                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  28.             }
  29.         };
  30.                
  31.            EndnuEnKlasse enKlasse = new EndnuEnKlasse("palle");
  32.            EndnuEnKlasse enKlasse1 = new EndnuEnKlasse("Oda");
  33.            EndnuEnKlasse enKlasse2 = new EndnuEnKlasse("Valborg");
  34.            
  35.            enKlasse.run();
  36.                
  37.        
  38.        
  39.     }
  40.    
  41. }
  42.  
  43. class EndnuEnKlasse implements Runnable{
  44.    
  45.     private String navn;
  46.  
  47.     public EndnuEnKlasse(String navn) {
  48.         this.navn = navn;
  49.     }
  50.  
  51.     public String getNavn() {
  52.         return navn;
  53.     }
  54.  
  55.     public void setNavn(String navn) {
  56.         this.navn = navn;
  57.     }
  58.  
  59.     @Override
  60.     public void run() {
  61.        
  62.         while(true) {
  63.            
  64.             System.out.println("hallo fra " + navn);
  65.            
  66.             try {
  67.                 Thread.sleep(1000);
  68.             } catch (InterruptedException ex) {
  69.                 Logger.getLogger(EndnuEnKlasse.class.getName()).log(Level.SEVERE, null, ex);
  70.             }
  71.         }
  72.        
  73.        
  74.     }
  75.  
  76.    
  77. }
  78.  
  79. interface IfKlasse {
  80.    
  81.     public void hej();
  82.    
  83. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top