Given it doesn't make sense to have multiple methods which do the same thing, it is logical and not at all surprising that different methods do different things with different arguments.
Firstly, why does the method Long (or Integer) take a String as a parameter in the valueOf method?
So it can parse the String and give you a Long
or Integer
as the docuemntation states.
and instead it takes a numeric primitive in the toString method?
valueOf turns a String into an object and toString takes a value and turns it into a String. Given these do almost the opposite things you would expect them to be the other way around.
Secondly, why does the first line of code listed below not work (by taking a String as first argument) whereas the second line works fine (by taking a long(or int) as first argument).
80
is a valid decimal which can be turned into an octal number. 80
is not a valid octal (or binary) so you cannot parse it as an octal.