A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

pottersheep

  • 5 years ago

What does is mean to make an instance of an object? - Java

  • This Question is Closed
  1. pottersheep
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Does it mean to create/name the array ??? I don't really get it.....

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Or think of an instance as the type, and the instance as a variable of that type. i.e: int i = 3 Your "class" would be int, and your "instance" would be i.

  4. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.