r/java • • Jun 02 '18

5 Java concepts explained: Overloading, overriding, shadowing, hiding, and obscuring

https://programming.guide/java/overloading-overriding-shadowing-hiding-obscuring.html
240 Upvotes

23 comments sorted by

View all comments

28

u/Hatefiend Jun 02 '18

Wow, I actually had no idea about obscuring.

1

u/ShlimDiggity Jun 02 '18

I just dealt with it in my intro to python last night, lol... Some example I looked up named a methods parameter (str). So I thought you were supposed to put the variable type as the parameter, as opposed to the name. I used int, then within the method tried calling int() to convert from string to int. No go! Obscured!

2

u/[deleted] Jun 02 '18

[removed] — view removed comment

2

u/ShlimDiggity Jun 02 '18

Yep, Java for sure won't let you name a variable int

1

u/[deleted] Jun 02 '18

[removed] — view removed comment

2

u/kalifornia_love Jun 02 '18

Gotten bit by that bug before...

FYI the “pythonic” way to get around this is to name your variable json_

Or use a better/different variable name.