Same name for different bindings [closed]

17 hours ago 3
ARTICLE AD BOX

Why the following code does not throw an error while I have used the same binding name.

I also tried ArrayList<Integer> task;

task = new Task(); ArrayList<Task> task;

Falak S.'s user avatar

3

Are you asking why you can't assign a value to a variable before you declare that variable? Also, how is your question related to JDBC? I see your other posts were about JavaScript. Note that Java is a very different language to JavaScript.

2026-03-26 04:29:22 +00:00

Commented 3 hours ago

can you show the entire code? For all we know, they're not in the same scope.

2026-03-26 06:05:36 +00:00

Commented 1 hour ago

@Abra my guess is, he's trying to figure out why he can have two variables with an identical name.

2026-03-26 07:20:08 +00:00

Commented 40 mins ago

Read Entire Article