Reputation: 89753
In VB.NET, we can surround a variable name with brackets and use keywords as variable names, like this:
Dim [new] As String = ""
C# equivalent:
string @new = "";
I was wondering is there a Java equivalent to doing this?
Upvotes: 10
Views: 6467
Reputation: 352
you can use the keyword @SerializedName("keyword")
. it will map Json node to the keyword specified when you receive a response from the server.
Upvotes: 1
Reputation: 2635
Welcome to the world of java.
The simple answer is , that is not possible.
Please read the specification for declaring variable names
http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html
Tut on variable declaration. http://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html
List of banned keywords that should be used as variables . http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
Cheers and keep learning!
Upvotes: 3
Reputation: 16143
You cannot use Java keywords as variables, method or class names.
Upvotes: 2
Reputation: 1200
No. You can add an underscores or somesuch nonsense, but basically keywords are off limits.
Upvotes: 10
Reputation: 160271
Nope.
Although you can do horrible things like this:
String String = "String";
If you wanted to be evil, you could use a unicode character and fake it.
Upvotes: 0