Access Millions of academic & study documents

6 In Java, Create a char variable called myChar and assign it the v

Content type
User Generated
Showing Page:
1/2
6. In Java, Create a char variable called myChar and
assign it the value e.
Solution
Good Wishes,
First let me give you the code:
public class Character
{
public static void main(String args[])
{
char myChar=\'e\';
System.out.println(\"The character is: \",myChar);
}
}
Explaination:
First I created a variable myChar
char myChar
Then I assigned \'e\' to it
char myChar=\'e\';
watch the single quotes
when we assign a value to a variable of type char we

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
6. In Java, Create a char variable called myChar and assign it the value e. Solution Good Wishes, First let me give you the code: public class Character { public static void main(String args[]) { char myChar=\'e\'; System.out.println(\"The character is: \",myChar); } } Explaination: First I created a variable myChar char myChar Then I assigned \'e\' to it char myChar=\'e\'; watch the single quotes when we assign a value to a variable of type char we should include it in single quotes Then I tried printing it System.out.println(\"The character is: \",mychar); I included this whole thing in ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4