Here you are: http://developer.android.com/reference/java/io/PrintStream.html#print%28float%29
Just one function could serve all the purposes:
public void print (Object o) {
if (o == null) {
// print "null"
} else {
// print o.toString();
}
}
More elaborations. For example, internal_print(String str)
is a function that write to the print stream. Then the only one function needed would be:
public void print (Object o) {
if (o == null) {
internal_print( "null" );
} else {
internal_print( o.toString() );
}
}
For other float
, int
, char
, long
, etc. overloadings, i can imagine they are just like:
public void print (float o) {
if (o == null) {
internal_print( "null" );
} else {
internal_print( o.toString() );
}
}
public void print (int o) {
if (o == null) {
internal_print( "null" );
} else {
internal_print( o.toString() );
}
}
public void print (char o) {
if (o == null) {
internal_print( "null" );
} else {
internal_print( o.toString() );
}
}
public void print (long o) {
if (o == null) {
internal_print( "null" );
} else {
internal_print( o.toString() );
}
}
...
Or even just calling the killer function print (Object o)
.
Could you please explain. Many thanks!!