Here is basically what I have:
public class Game extends Activity{
public class Work{
public class Shuffle{
*Class I need to access*
}
}
}
Here is the class I will be accessing Shuffle from:
public class Deck extends Game {
public int shuffle() {
//WHAT DO I NEED TO DECLARE HERE IN ORDER TO ACCESS Shuffle.getShuffle()?
int[] shuffDeck = (MY SHUFFLE CLASS).getShuffle();
int x = shuffDeck[i];
String y = String.valueOf(x);
i += 1;
return x;
}
}
What do I need to declare to be able to access Shuffle.getShuffle() in my Deck class?
Now taking of Nested Classes its of 2 types :
1.
Inner Classes(Non-static)2.
Top Level Classes(static)–
Inner Class (Non-static) has an Implicit Reference to itsOuter Class(Enclosing Class).To access an Inner Class from outside you need to access it using the Outer Class Object.
Eg:
– A
Top-Level Class(static) is just like a separate class in the Outer Class.Top-levelclass needs to create an object of the Outer Class to access its Non-static members, but It can Access theStatic methods and Static variablesof the Outer class directly.Eg: