Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Can Java have same name variable

Why Java not having same name variables ?
Ans.

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 = “EasyExamNotes.com”;

System.out.println(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.