Objects light switch lab
mentors_revature June 27 |
@sacvelazquez424 “Creating Objects” refers to the creation of a reference variable and using the ‘new’ keyword with a constructor of a class. For instance, if you create an ‘Example’ class and create an ‘Example’ object it would look something like this:
Example.java file:
class Example {
// class code…
}
Main.java file:
class Main {
public static void main(String[] args) {
Example exVariable = new Example();
}
}
In the code above, the ‘new Example()’ is the call to the class constructor using the keyword ‘new’, and the ‘Example exVariable’ creates the reference variable, specifically the reference variable is named ‘exVariable’
I'm stuck on the objects light switch i asked for help and this is what i got, I'm drawing a blank, this answer when in one ear and out the other
Please sign in to leave a comment.
Comments
0 comments