i'm going crazy! isn't character
constructor supposed e char
argument?
why when try compile this, gives me compile error:
public class testclass { public static void main(string[] args) { char c = 'a'; character cobj = new character(c); } }
the error is:
testclass.java:5: error: constructor character in class character cannot applied given types; character cobj = new character(c); ^ required: no arguments found: char reason: actual , formal argument lists differ in length 1 error
also, if try compile this:
public class testclass { public static void main(string[] args) { char c = 'a'; character cobj = character.valueof(c); } }
i get:
testclass.java:5: error: cannot find symbol character cobj = character.valueof(c); ^ symbol: method valueof(char) location: class character 1 error
this happening on macos sierra 10.12.6 latest oracle java version "1.8.0_144".
if try compile same code on linux using openjdk 8, compiles should.
what missing?
since java supports boxing primitives wrapper class can do
character cobj = 'a';
or
char c = 'a'; character cobj = c;
but eventhoe not necessary have work
char c = 'a'; character cobj = new character(c);
be sure importing right class java.lang.character
Comments
Post a Comment