Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java get variable from another class

public class Class1 {
	public static String word = "Class1 word";
    
    public Class1() {
    	String class2Word = Class2.word; // Get string "word" from class "Class2".
    }
}

public class Class2 {
	public static String word = "Class2 word";
}
 
PREVIOUS NEXT
Tagged: #java #variable #class
ADD COMMENT
Topic
Name
2+8 =