fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. public class TV {
  13. int canal;
  14. int volume;
  15. boolean ligada;
  16. int tamanho;
  17.  
  18. public TV(){
  19. this.tamanho = 21;
  20. this.ligada = false;
  21. this.canal = 0;
  22. this.volume = 0;
  23. }
  24.  
  25. // método da classe
  26. public void ligar(boolean ligada){
  27. this.ligada = ligada;
  28. }
  29.  
  30. // função
  31. public static void estahLigada (TV objeto){
  32. if (objeto.ligada)
  33. System.out.println ("está ligada");
  34. else
  35. System.out.println ("não está ligada");
  36. }
  37.  
  38. public static void main (String args []){
  39. TV televisao1 = new TV();
  40. TV televisao2 = new TV();
  41. // chamando o método ligar
  42. televisao1.ligar(true);
  43. televisao2.ligar(false);
  44. System.out.print ("A televisão 1 ");
  45. // chamando a função estahLigada
  46. estahLigada (televisao1);
  47. System.out.print ("A televisão 2 ");
  48. estahLigada (televisao2);
  49. }
  50. }
  51.  
  52. }
  53. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:12: error: illegal start of expression
public class TV {
^
1 error
stdout
Standard output is empty