Can Java have same name variable

Why Java not having same name variables ?

As a computer faculty, I found following reason during practise;
Consider this example:

class EEN {

public static void main(String args[]) {

int b = 10;

String b = “”;



In above Java program example, there are two variables with name b, one is having type int, another is having type String with different values.

When I am printing value of b, Java compiler will get confuse, which variable b to be print.

Because there is no format specifier (%d,%c,%f) in Java like C programming.

That is the reason Java programming not having same name of variables.