• Post Reply Bookmark Topic Watch Topic
  • New Topic

calling char value  RSS feed

 
nicky priya
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Hello everyone, i have doubt in 'char' datatype. how can we call the char method into main method. for example here in this program we are calling all types of datatype such as int, double, short, and doing addition,subtraction, multiplication and division. i want to call even the char by giving any name as value how is it possible.

 
Carey Brown
Saloon Keeper
Posts: 3329
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When posting code please high light your code and use the "Code" button above the edit box. I fixed it for you this time.
 
Carey Brown
Saloon Keeper
Posts: 3329
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On line 19 in the name() method you declare a char variable with the name 'z'. This variable is local to and only visible inside name(). Your main() method does not have a 'z' variable so you are getting this error.

In addition your name() method is expecting two char values and in main() you are only calling it with one. You'd need something like:
Also note that "James" is a String, not a char, so you can't do
 
nicky priya
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
color=black] [/color]

i am sorry i'll do it from next time Thank you.[
 
nicky priya
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can I get out put as  name such as 'James Gosling'  instead of a b.
 
nicky priya
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Okay i got it. Thank you very much.
 
Carey Brown
Saloon Keeper
Posts: 3329
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
nicky priya
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!