Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Java Method

variable type

  • Please log in to reply
5 replies to this topic

#1 yourmom615

yourmom615

    CC Regular

  • Just Joined
  • PipPipPip
  • 33 posts

Posted 19 March 2011 - 08:03 AM

Can char variable type be used in a Java method? Can the method using char be overloaded? If so can I get an example!! It doesn't need to be code I am just trying to figure out if you can use char in methods??
  • 0

#2 Simonxz

Simonxz

    CC Regular

  • Just Joined
  • PipPipPip
  • 42 posts

Posted 19 March 2011 - 08:43 AM

Yes,

public char somecharfunc(char a, char b) {
    return a;
}

public char somecharfunc(char a) {
    return a;
}

You can overload any type, return any type and receive any type.
  • 0

#3 yourmom615

yourmom615

    CC Regular

  • Just Joined
  • PipPipPip
  • 33 posts

Posted 19 March 2011 - 09:33 AM

Ok..thanks..so it is easy to assume you cannot mix the variable types for obvious reasons, exmple........
public int intOne(double val1, char b)

This would be incorrect, right?
  • 0

#4 Simonxz

Simonxz

    CC Regular

  • Just Joined
  • PipPipPip
  • 42 posts

Posted 19 March 2011 - 11:08 AM

No, this is correct, you just need to make sure it returns a int.
  • 0

#5 yourmom615

yourmom615

    CC Regular

  • Just Joined
  • PipPipPip
  • 33 posts

Posted 19 March 2011 - 11:36 AM

Thats the problem it doesnt diplay anything when the code is ran...anything obvious??
  • 0

#6 yourmom615

yourmom615

    CC Regular

  • Just Joined
  • PipPipPip
  • 33 posts

Posted 19 March 2011 - 11:40 AM

Nevermind wrong thread...sorry

Edited by yourmom615, 20 March 2011 - 12:17 PM.

  • 0





Also tagged with one or more of these keywords: variable type

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download