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

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 1.05 KB  |  hits: 9  |  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. Cannot make a static reference to the non-static method fxn(int) from the type Two [closed]
  2. class Two {
  3.     public static void main(String[] args) {
  4.         int x = 0;
  5.  
  6.         System.out.println("x = " + x);
  7.         x = fxn(x);
  8.         System.out.println("x = " + x);
  9.     }
  10.  
  11.     int fxn(int y) {
  12.         y = 5;
  13.         return y;
  14.     }
  15. }
  16.        
  17. public static int fxn(int y) {
  18.     y = 5;
  19.     return y;
  20. }
  21.        
  22. Two two = new Two();
  23. x = two.fxn(x);
  24.        
  25. ...
  26. Two two = new Two();
  27. x = two.fxn(x)
  28. ...
  29.        
  30. public class Two {
  31.  
  32.  
  33.     public static void main(String[] args) {
  34.         int x = 0;
  35.  
  36.         System.out.println("x = " + x);
  37.         x = fxn(x);
  38.         System.out.println("x = " + x);
  39.     }
  40.  
  41.     static int fxn(int y) {
  42.         y = 5;
  43.         return y;
  44.     }
  45.        
  46. public class A
  47.        {
  48.            public   int fxn(int y) {
  49.               y = 5;
  50.               return y;
  51.           }
  52.        }
  53.  
  54.  
  55.   class Two {
  56. public static void main(String[] args) {
  57.     int x = 0;
  58.     A a = new A();
  59.     System.out.println("x = " + x);
  60.     x = a.fxn(x);
  61.     System.out.println("x = " + x);
  62. }