Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
my code looks like this:
Student jackNapoli = new Student(3, Jack, Napoli, The_Lawyer99#yahoo.com, 19, 85,84,87);
I am trying to create an new object of the Student class. My problem is the # symbol in the email address. How do I get this to not show up as error?
The problem is not in the # symbol.
The way you are passing the parameters to Student, Jack, Napoli and The_Lawyer99#yahoo.com are seen as object.
The compiler might tell you the problem is with the # because it is reserved for annotation in java. However, the real problem is that you probably want to pass these values as string using quotes.
Student jackNapoli = new Student(3, "Jack", "Napoli", "The_Lawyer99#yahoo.com", 19, 85,84,87);
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 days ago.
Improve this question
I have a string like "{hello}{bye}"
How can I split() the string so my output is ["{hello}, "{bye}"]
I have tried splitting with "}{" but it leaves me without the }{.
Have also tried .split("((?<=})|(?={))") but I get a "number expected" syntax error beneath the {
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 months ago.
Improve this question
I am using jdk 19 and want to make a record class for my Java project.
When I declare the class Person:
public record Person (String name) {}
I get the error
'class' or 'interface' expected
I don't understand why it will not let me use the record keyword.
Any help is appreciated
The records feature arrived in Java 16.
Project language level is selected to be 15, why didn't you change?
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
String names = "Peter, John, Andy, David";
String [] splitNames = names.split(",");
System.out.println(Arrays.tostring(splitNames(','));
I am beginner and I am trying to correct the code to the end result of my question listed. I am teaching myself from a book which has no listed details. If someone could assist that would be great. Thank you! I think I am on the right path I am overlooking my mistake.
This is easier to accomplish with the Stream api that was introduced in Java 8:
System.out.println(
Arrays.stream(splitNames)
.collect(Collectors.joining(", ", "{", "}"))
);
Here's a good tutorial for Stream collectors: https://www.baeldung.com/java-8-collectors
Just correct this line:
System.out.println(Arrays.tostring(splitNames(','));
to:
System.out.println(Arrays.toString(splitNames));
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I get this error when I try to do an Onclicklistener to my customInfoWndow
The code for that is specifically this:
(GoogleMap.OnInfoWindowClickListener((new GoogleMap.OnInfoWindowClickListener))
How may I solve this error.
Thanks a lot!
You have a new keyword, so you're constructing an object. If the constructor takes no parameters, you must put empty braces anyway:
new GoogleMap.OnInfoWindowClickListener()
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I guess its a rather simple question but i just cant find my mistake.
int[] myIntArray = new int[20];
myIntArray[5] = 5;
int a = myIntArray[5];
TextIO.putf("arr[i]: d%",a );
The error I get is Illegal format string in TextIO.putf() method.
So I assume the value at the index 5 is not an int?
The error message says exactly what the problem is: your format string is wrong. You probably meant %d (or better yet, %d%n to add a newline).
The format string elements are in the form
%[modifiers]type
not
something%
Change d% to %d.