What does is mean to make an instance of an object? - Java
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
Does it mean to create/name the array ??? I don't really get it.....
Think of a class in java like a cookie mold, You can make an infinite amount of cookies with that mold. Now think every object created by the class as the cookie. The act of creating any object, is creating an "instance" of the class. You never really create an instant of an object, unless your getting into inheritance.
Or think of an instance as the type, and the instance as a variable of that type.
int i = 3
Your "class" would be int, and your "instance" would be i.
Not the answer you are looking for? Search for more explanations.
Although the is an Object class in Java that is extended by many other classes, dmelando is right. In OOP you make an instance of a class not of an object, but that instance of a class is an object of that class. Think of it this way: Corvette is a model (class) of car. It has a specific definition (how it is made, what it looks like, how fast it can go, etc). Now I can sit here and talk about the Corvette all day, but all I have is the definition (class). Now, I take that definition and actually make a Corvette. I have now made an instance of the class Corvette and that instance is an object that I can manipulate. The ways that I can manipulate it are defined by the class. In other words, I can make it go forwards and backwards because those are its methods, those functions are in it's class definition, but I cannot make it fly.
So for a practical example, let's use the Java class Date since it is simple. Date is a native Java class that you can use to create date and time objects. So for example:
DateFormat df = new SimpleDateFormat("MM/dd/yy");
String formattedDate = df.format(new Date());
creates a date object in the format MM/dd/yy, and
DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
String formattedDate = df.format(theDate);
creates a date object in the format yyyy/MM/dd
Now I can use these objects to display the date, calculate a leap year, determine someone's sign after they enter their birth date, etc. And the specific instance of the date object that i make is going to depend on what i am using it for.