Creating car class object instance
Using classes, we can create object instances that perform operations within our code. We are going to create an instance of the Car class.
NOTE: We added a new keyword, static, on the Car class. We will learn about the static keyword later, but for now, it is required for your code to run correctly within the editor.
Bu egzersiz
Introduction to Object-Oriented Programming in Java
kursunun bir parçasıdırEgzersiz talimatları
- Create a new object instance of the
Carclass calledmyCarinside themainmethod of theMainclass.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
class Main {
static class Car {
}
public static void main(String[] args) {
// Complete the creation of a new object instance for the Car class
Car ____ = ____ Car();
}
}