How single line Java comment is accepted without starting by //? [duplicate] - java

This question already has answers here:
A URL specified in a separate line in Java doesn't issue compile-time errors. Why?
(3 answers)
Java Label usage [duplicate]
(2 answers)
Closed 4 years ago.
When I put some comments on my Java code
I miss to put // in the start of the comment line (its content: url)
I expect compilation error but i surprised the comment line is accepted!
Note: I use Java7
// below single line java comment is accepted without starting by //
https://www.google.com/
Kindly any explanation?

Thanks to #Stultuske comment
Yes - thats is accepted because
https: conidered as a java label then the reaming part
//www.google.com/ conidered as a valid java comment
.
// below single line java comment is accepted without starting by //
https://www.google.com/
for(..,..,..){
}

Related

What does the number after # in thread view in Intellij IDEA mean? [duplicate]

This question already has answers here:
While debugging java app what information is shown for a variable in a stack frame [duplicate]
(3 answers)
Closed 4 years ago.
What does 954 mean? I have checked both thread's id and hashcode(), but they don't equal 954.
Also, when using evaluate, there is also a number after #, I think they have the same meaning but still couldn't find out what's the meaning.
Interesting question. I just always took for granted that it is some id that uniquely identifies the object.
Based on that assumption it could for example be the uniqueId() returned by the Java Debugger Interface for an ObjectReference:
https://docs.oracle.com/javase/7/docs/jdk/api/jpda/jdi/
But that is really just an assumption.

Java syntax: { ... } - What's that? [duplicate]

This question already has answers here:
Labeled Statement block in Java?
(4 answers)
Closed 5 years ago.
some time ago I randomly saw (in a decompiled Java code) something like this:
syntax: {
//some code
}
What does this do? And is there more stuff like this?
I was not able to find anything about this.
Greetings
I think this is called a label. And can be used with loops. See also using labels in java without "loops"
Apart from labels if you remove : from start
{ } can be used as init block which is used to write code that will execute as first line in constructor.

Can we use camel case in java package naming? [duplicate]

This question already has answers here:
What is the convention for word separator in Java package names?
(6 answers)
Closed 6 years ago.
For example:
Which of the following package names is correct?
com.google.payrolldivision;
or
com.google.payrollDivision;
Please just answer the question without beating around the bush?
Please just answer the question
OK, then taking your question as a "a xor b", the answer is
com.google.payrolldivision;
as per https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html.
However, your title and post ask two very different questions, so it's hard to "just answer the question".
According to the Oracle webpage, you should write your package name in lowercase.
Package names are written in all lower case to avoid conflict with the names of classes or interfaces.

Autocomplete ArrayList declaration [duplicate]

This question already has answers here:
IntelliJ IDEA 12 code completion without capitalisation
(2 answers)
Closed 7 years ago.
Can IntelliJ Idea autocomplete my arraylist declaration if I
entered typename with lower case?
When I type ArrayL starting with capital letter I'm getting autocompletetion instantly.
But if I start typing arraylist with lowercase I can not get autocompletetion in any way. I tried ctrl-space, ctrl-shift-space but none of them works for me.
Maybe you can check this answer. Not sure if it is exactly the same currently, since this link refers to version 12 and current is 15:
IntelliJ IDEA 12 code completion without capitalisation

Java Unicode String is null? [duplicate]

This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 8 years ago.
I want to print a box into the Java console using Unicode characters, but for some reason it gives me this runtime error:
--------------------Configuration: PacManGame - JDK version 1.7.0_25 <Default> - <Default>--------------------
Exception in thread "main" java.lang.NullPointerException
at Scoreboard.genTopLine(Scoreboard.java:35)
at Scoreboard.<init>(Scoreboard.java:17)
at PacManGame.main(PacManGame.java:36)
Process interrupted by user.
code: http://pastebin.com/nuAsH857
Does anyone know what's wrong?
topline is actually NOT null - it's perfectly fine.
The problem is the use of System.console() which returns null (and hence you get NPE on .writer()).
Use System.out.println() instead and it'll work just fine.
An explanation as to why System.console() doesn't work in your IDE can be found here

Categories