Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Keywords as a variable

Tags:

java

variables

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?

like image 387
Pacerier Avatar asked Nov 11 '11 21:11

Pacerier


People also ask

Can keywords be used as variables?

We cannot use a keyword as a variable name, function name or any other identifier. They are used to define the syntax and structure of the Python language. In Python, keywords are case sensitive.

Which keyword is used to declare a variable in Java?

Java 10 introduced a new way to declare variables using the var keyword.


1 Answers

No. You can add an underscores or somesuch nonsense, but basically keywords are off limits.

like image 190
Mike Adler Avatar answered Sep 29 '22 21:09

Mike Adler