Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Default value of primitive type char

$
0
0
public class Test
{
	char ch1 = '\u0000';
	char ch2;
	char ch3 = ' ';
	
	public static void main(String [] args)
	{
		// Do something...
	}
}

In the code above, (if I understand correctly), the values for ch1 and ch2 are null which is represented by whitespace. However, I am curious, is the value for ch3 also null (which is also represented by whitespace). Are all three variables interchangeable or just ch1 and ch2? Any feedback is much appreciated.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>