fork download
  1. import java.util.*;
  2.  
  3. class mymath {
  4. long a;
  5. long b;
  6.  
  7. long add() {
  8. System.out.print("instance");
  9. return a + b;
  10. }
  11.  
  12. long sub() {
  13. System.out.println("instance");
  14. return a - b;
  15. }
  16.  
  17. long mul() {
  18. System.out.println("instance");
  19. return a * b;
  20. }
  21.  
  22. long div() {
  23. System.out.println("instance");
  24. return a / b;
  25. } // 그냥 메소드
  26.  
  27. static long add(long a, long b) {
  28. return a + b;
  29. }
  30.  
  31. static long sub(long a, long b) {
  32. return a - b;
  33. }
  34.  
  35. static long mul(long a, long b) {
  36. return a * b;
  37. }
  38.  
  39. static long div(long a, long b) {
  40. return a / b;
  41. }
  42. }
  43.  
  44. public class static_method {
  45. public static void main(String[] args) {
  46. System.out.println(mymath.add(20L, 30L));
  47. mymath start = new mymath();
  48. start.a = 100L;
  49. start.b = 200L;
  50. System.out.println(start.add());
  51. }
  52.  
  53. }
  54.  
  55. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:55: error: class, interface, or enum expected
}
^
1 error
stdout
Standard output is empty