Home > Net >  I am getting an Invalid Character Constant when using brackets inside quotes [duplicate]
I am getting an Invalid Character Constant when using brackets inside quotes [duplicate]

Time:09-21

My code:

String blockstates = '{\n\t"variants":    {\n\t\t"":"model":"mod:block/'   blockname   " }\n\t}\n}";`

The error that I am getting is an Invalid Character constant of '{ at the start of the string. Is there a way I can fix this?

CodePudding user response:

Strings in java are enclosed in ". you are using ' . Correct way to write :

String blockstates = "{\n\t\"variants\": {\n\t\t\"\":\"model\":\"mod:block/\"   blockname   \" }\n\t}\n}";

CodePudding user response:

Characters in java are enclosed in ' (single quotes)

Character char = 'c'; //correct
Character char = 'cc'; //will not compile
  • Related