This site requires JavaScript, please enable it in your browser!
Greenfoot back
divinity
divinity wrote ...

2016/1/16

initializing a char variable

divinity divinity

2016/1/16

#
hi good morning all i am doing ah program and am using a character like this char grde; my question is does it have to be initialize and if so how do i initialize. it is a character
danpost danpost

2016/1/16

#
Usually, primitive type variables do not need to be initialized. However, you could set it to some default value (' ', for example) or (since it has a numeric value) you could set it to zero.
divinity divinity

2016/1/16

#
char grde=''; when i put it like this I am getting a syntax error but when I put a letter either A or B or may C the syntax is gone but i dont want it like that . I want it to accept any letter grade. how do i do that
danpost danpost

2016/1/16

#
divinity wrote...
char grde=''; when i put it like this I am getting a syntax error but when I put a letter either A or B or may C the syntax is gone but i dont want it like that . I want it to accept any letter grade. how do i do that
I did not have nothing between the single quotes -- I had a space character in there. I thought that maybe you could use that as an unassigned grade character.
You need to login to post a reply.