• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

input/output

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
jqplus 953747327710
Which of these are valid parameter type for the write()methods of the Writer class?
R int: is good
R char: is wrong
But I think that the char will be converted to an int and the mehod should work.
??
..Cristian
 
Ranch Hand
Posts: 1246
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
write() only take
char[] cbuf,
int c,
and String str.

http://java.sun.com/j2se/1.4/docs/api/java/io/Writer.html
 
Cristian Negresco
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
And why if I will give a char as parameter it will not be promoted to an int?
See the following lines:
public class TestChar
{
static void m(int i)
{
System.out.println("OK, a received an int!");
}
public static void main(String args[])
{
char test = 'a';
m(3);
m(test);
}
}
In this case the char is converted to an int.
Why in the case I was talking about the things are not the same?
Thanks.
..Cristian
 
Ranch Hand
Posts: 782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well it's a bit confusing question thouh it is quite simple .
I have done it practically and check the following code.It compiles & runs fine.

------------------
Count the flowers of ur garden,NOT the leafs which falls away!
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then both the int and char should be right.
reply
    Bookmark Topic Watch Topic
  • New Topic