Jump to content

Java Method

- - - - -

  • Please log in to reply
5 replies to this topic

#1
yourmom615

yourmom615

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
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??

#2
Simonxz

Simonxz

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
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.

#3
yourmom615

yourmom615

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
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?

#4
Simonxz

Simonxz

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
No, this is correct, you just need to make sure it returns a int.

#5
yourmom615

yourmom615

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
Thats the problem it doesnt diplay anything when the code is ran...anything obvious??

#6
yourmom615

yourmom615

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
Nevermind wrong thread...sorry

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users