Java 11 syntax error calling class properties (Car) from another class (Main)
**I need help, I'm learning java in the Linked-in paid for course.
The problem is when I try calling class properties from another class to 'Build a car' I get syntax errors and I need help here is the code if anyone could explain what is going wrong I would really appreciate it thanks in advance !
import java.awt.*;
public class Main {
public static void main(String args) {
System.out.println("Hello World");
System.out.println("Peter");
Car myCar = new Car(inputAverageMPG: 25.5,
inputLicensePlate "1BC32E",
Color.BLUE,
inputTailLightsWorking: true);
}
}
Here is the Car class
public class Car {
// Data Types:
// int -> integer 1, 2, 3
// double -> decimal 34.5, 32.1
// String -> "a1a2" or "Hello World"
// Color -> from awt library
// boolean -> true or false
double averageMilesPerGallon;
String licensePlate;
Color painColor;
boolean areTailLightsWorking;
public Car(int inputAverageMPG,
String inputLicensePlate,
Color inputPaintColor,
boolean inputAreTailLightsWorking) {
this.averageMilesPerGallon = inputAverageMPG;
this.licensePlate = inputLicensePlate;
this.areTailLightsWorking = inputAreTailLightsWorking;
this.painColor = inputPaintColor;
}
}
Here are my error messages (including lines)
Line 9: Cannot resolve symbol (inputAverageMPG)
Line 10 Cannot resolve symbol (inputLicensePlate)
Line 12 Cannot resolve symbol (inputTailLightsWorking)
java class
add a comment |
**I need help, I'm learning java in the Linked-in paid for course.
The problem is when I try calling class properties from another class to 'Build a car' I get syntax errors and I need help here is the code if anyone could explain what is going wrong I would really appreciate it thanks in advance !
import java.awt.*;
public class Main {
public static void main(String args) {
System.out.println("Hello World");
System.out.println("Peter");
Car myCar = new Car(inputAverageMPG: 25.5,
inputLicensePlate "1BC32E",
Color.BLUE,
inputTailLightsWorking: true);
}
}
Here is the Car class
public class Car {
// Data Types:
// int -> integer 1, 2, 3
// double -> decimal 34.5, 32.1
// String -> "a1a2" or "Hello World"
// Color -> from awt library
// boolean -> true or false
double averageMilesPerGallon;
String licensePlate;
Color painColor;
boolean areTailLightsWorking;
public Car(int inputAverageMPG,
String inputLicensePlate,
Color inputPaintColor,
boolean inputAreTailLightsWorking) {
this.averageMilesPerGallon = inputAverageMPG;
this.licensePlate = inputLicensePlate;
this.areTailLightsWorking = inputAreTailLightsWorking;
this.painColor = inputPaintColor;
}
}
Here are my error messages (including lines)
Line 9: Cannot resolve symbol (inputAverageMPG)
Line 10 Cannot resolve symbol (inputLicensePlate)
Line 12 Cannot resolve symbol (inputTailLightsWorking)
java class
Please include the error message that you are getting.
– Thilo
Nov 25 '18 at 13:41
Ok I will edit now sorry.
– Evil Exists
Nov 25 '18 at 13:41
2
Just remove the argument identifiers.Car myCar = new Car(25.5, "1BC32E", Color.blue, true);
– zlakad
Nov 25 '18 at 13:42
Does Java 11 have named arguments in method calls now?
– Thilo
Nov 25 '18 at 13:42
C# has argument identifiers, Java doesn't.
– Guy
Nov 25 '18 at 13:44
add a comment |
**I need help, I'm learning java in the Linked-in paid for course.
The problem is when I try calling class properties from another class to 'Build a car' I get syntax errors and I need help here is the code if anyone could explain what is going wrong I would really appreciate it thanks in advance !
import java.awt.*;
public class Main {
public static void main(String args) {
System.out.println("Hello World");
System.out.println("Peter");
Car myCar = new Car(inputAverageMPG: 25.5,
inputLicensePlate "1BC32E",
Color.BLUE,
inputTailLightsWorking: true);
}
}
Here is the Car class
public class Car {
// Data Types:
// int -> integer 1, 2, 3
// double -> decimal 34.5, 32.1
// String -> "a1a2" or "Hello World"
// Color -> from awt library
// boolean -> true or false
double averageMilesPerGallon;
String licensePlate;
Color painColor;
boolean areTailLightsWorking;
public Car(int inputAverageMPG,
String inputLicensePlate,
Color inputPaintColor,
boolean inputAreTailLightsWorking) {
this.averageMilesPerGallon = inputAverageMPG;
this.licensePlate = inputLicensePlate;
this.areTailLightsWorking = inputAreTailLightsWorking;
this.painColor = inputPaintColor;
}
}
Here are my error messages (including lines)
Line 9: Cannot resolve symbol (inputAverageMPG)
Line 10 Cannot resolve symbol (inputLicensePlate)
Line 12 Cannot resolve symbol (inputTailLightsWorking)
java class
**I need help, I'm learning java in the Linked-in paid for course.
The problem is when I try calling class properties from another class to 'Build a car' I get syntax errors and I need help here is the code if anyone could explain what is going wrong I would really appreciate it thanks in advance !
import java.awt.*;
public class Main {
public static void main(String args) {
System.out.println("Hello World");
System.out.println("Peter");
Car myCar = new Car(inputAverageMPG: 25.5,
inputLicensePlate "1BC32E",
Color.BLUE,
inputTailLightsWorking: true);
}
}
Here is the Car class
public class Car {
// Data Types:
// int -> integer 1, 2, 3
// double -> decimal 34.5, 32.1
// String -> "a1a2" or "Hello World"
// Color -> from awt library
// boolean -> true or false
double averageMilesPerGallon;
String licensePlate;
Color painColor;
boolean areTailLightsWorking;
public Car(int inputAverageMPG,
String inputLicensePlate,
Color inputPaintColor,
boolean inputAreTailLightsWorking) {
this.averageMilesPerGallon = inputAverageMPG;
this.licensePlate = inputLicensePlate;
this.areTailLightsWorking = inputAreTailLightsWorking;
this.painColor = inputPaintColor;
}
}
Here are my error messages (including lines)
Line 9: Cannot resolve symbol (inputAverageMPG)
Line 10 Cannot resolve symbol (inputLicensePlate)
Line 12 Cannot resolve symbol (inputTailLightsWorking)
java class
java class
edited Nov 25 '18 at 13:49
Evil Exists
asked Nov 25 '18 at 13:39
Evil ExistsEvil Exists
368
368
Please include the error message that you are getting.
– Thilo
Nov 25 '18 at 13:41
Ok I will edit now sorry.
– Evil Exists
Nov 25 '18 at 13:41
2
Just remove the argument identifiers.Car myCar = new Car(25.5, "1BC32E", Color.blue, true);
– zlakad
Nov 25 '18 at 13:42
Does Java 11 have named arguments in method calls now?
– Thilo
Nov 25 '18 at 13:42
C# has argument identifiers, Java doesn't.
– Guy
Nov 25 '18 at 13:44
add a comment |
Please include the error message that you are getting.
– Thilo
Nov 25 '18 at 13:41
Ok I will edit now sorry.
– Evil Exists
Nov 25 '18 at 13:41
2
Just remove the argument identifiers.Car myCar = new Car(25.5, "1BC32E", Color.blue, true);
– zlakad
Nov 25 '18 at 13:42
Does Java 11 have named arguments in method calls now?
– Thilo
Nov 25 '18 at 13:42
C# has argument identifiers, Java doesn't.
– Guy
Nov 25 '18 at 13:44
Please include the error message that you are getting.
– Thilo
Nov 25 '18 at 13:41
Please include the error message that you are getting.
– Thilo
Nov 25 '18 at 13:41
Ok I will edit now sorry.
– Evil Exists
Nov 25 '18 at 13:41
Ok I will edit now sorry.
– Evil Exists
Nov 25 '18 at 13:41
2
2
Just remove the argument identifiers.
Car myCar = new Car(25.5, "1BC32E", Color.blue, true);
– zlakad
Nov 25 '18 at 13:42
Just remove the argument identifiers.
Car myCar = new Car(25.5, "1BC32E", Color.blue, true);
– zlakad
Nov 25 '18 at 13:42
Does Java 11 have named arguments in method calls now?
– Thilo
Nov 25 '18 at 13:42
Does Java 11 have named arguments in method calls now?
– Thilo
Nov 25 '18 at 13:42
C# has argument identifiers, Java doesn't.
– Guy
Nov 25 '18 at 13:44
C# has argument identifiers, Java doesn't.
– Guy
Nov 25 '18 at 13:44
add a comment |
1 Answer
1
active
oldest
votes
java syntax works like this:
Car myCar = new Car(25.5, "1BC32E", Color.BLUE, true);
No need to append variable name while passing values, only constraint here is type of value and parameter index should match.
I will try this now. Thanks.
– Evil Exists
Nov 25 '18 at 13:50
Yes this works thanks a bunch the lady who I was following was using java 9.'Something' that's why it wasn't working different versions and all !
– Evil Exists
Nov 25 '18 at 13:53
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53468041%2fjava-11-syntax-error-calling-class-properties-car-from-another-class-main%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
java syntax works like this:
Car myCar = new Car(25.5, "1BC32E", Color.BLUE, true);
No need to append variable name while passing values, only constraint here is type of value and parameter index should match.
I will try this now. Thanks.
– Evil Exists
Nov 25 '18 at 13:50
Yes this works thanks a bunch the lady who I was following was using java 9.'Something' that's why it wasn't working different versions and all !
– Evil Exists
Nov 25 '18 at 13:53
add a comment |
java syntax works like this:
Car myCar = new Car(25.5, "1BC32E", Color.BLUE, true);
No need to append variable name while passing values, only constraint here is type of value and parameter index should match.
I will try this now. Thanks.
– Evil Exists
Nov 25 '18 at 13:50
Yes this works thanks a bunch the lady who I was following was using java 9.'Something' that's why it wasn't working different versions and all !
– Evil Exists
Nov 25 '18 at 13:53
add a comment |
java syntax works like this:
Car myCar = new Car(25.5, "1BC32E", Color.BLUE, true);
No need to append variable name while passing values, only constraint here is type of value and parameter index should match.
java syntax works like this:
Car myCar = new Car(25.5, "1BC32E", Color.BLUE, true);
No need to append variable name while passing values, only constraint here is type of value and parameter index should match.
answered Nov 25 '18 at 13:42
Dark KnightDark Knight
6,33442749
6,33442749
I will try this now. Thanks.
– Evil Exists
Nov 25 '18 at 13:50
Yes this works thanks a bunch the lady who I was following was using java 9.'Something' that's why it wasn't working different versions and all !
– Evil Exists
Nov 25 '18 at 13:53
add a comment |
I will try this now. Thanks.
– Evil Exists
Nov 25 '18 at 13:50
Yes this works thanks a bunch the lady who I was following was using java 9.'Something' that's why it wasn't working different versions and all !
– Evil Exists
Nov 25 '18 at 13:53
I will try this now. Thanks.
– Evil Exists
Nov 25 '18 at 13:50
I will try this now. Thanks.
– Evil Exists
Nov 25 '18 at 13:50
Yes this works thanks a bunch the lady who I was following was using java 9.'Something' that's why it wasn't working different versions and all !
– Evil Exists
Nov 25 '18 at 13:53
Yes this works thanks a bunch the lady who I was following was using java 9.'Something' that's why it wasn't working different versions and all !
– Evil Exists
Nov 25 '18 at 13:53
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53468041%2fjava-11-syntax-error-calling-class-properties-car-from-another-class-main%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please include the error message that you are getting.
– Thilo
Nov 25 '18 at 13:41
Ok I will edit now sorry.
– Evil Exists
Nov 25 '18 at 13:41
2
Just remove the argument identifiers.
Car myCar = new Car(25.5, "1BC32E", Color.blue, true);
– zlakad
Nov 25 '18 at 13:42
Does Java 11 have named arguments in method calls now?
– Thilo
Nov 25 '18 at 13:42
C# has argument identifiers, Java doesn't.
– Guy
Nov 25 '18 at 13:44