Search Results

Search found 1 results on 1 pages for 'nazerb'.

Page 1/1 | 1 

  • Java Passing variables around classes

    - by nazerb
    I am new to java and am trying to pass variables like in the following example from one class to another, im wondering is this possible and how i would go about it if it is. As this code does not work as it is not static. Main Class public class testAll { public static void main(String[] args) { One one = new One(); Two two = new Two(); } } The first class: public class One { public int test = 4; public int getTest() { return this.test; } } The second class: public class Two { public void value() { System.out.print("Var is: " + One.getTest()); } } Thanks, Naz

    Read the article

1