/* Access Variables
objectName.variableName; this way is very rare mostly you use methods to get variables
Access Methods
objectName.methodName; */
Example;
public class CarApp{
public static void main(String[] args){
Tesla redTesla = new Tesla(5,56999,..);
Tesla blueTesla = new Tesla(4,66999,..);
// accessing
redTesla.getPrice(); // returns 56999
blueTesla.getSeat(); // returns 4
redTesla.startEngine() // returns the engine is started
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter