Re: very new to java
- From: Hendrik Maryns <hendrik_maryns@xxxxxxxxxxxxx>
- Date: Mon, 25 Sep 2006 11:28:20 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
porky008 schreef:
i am very new as you can see. what am i doing wrong here. any help
would nice
public class Welcome
{
// main method begins execution of Java application
public static void main( String args[] )
{
System.out.printf( %s \n%s \n,
"Hi, my name is xxx.", "I was born in xxx.");
} // end method main
} // end class Welcome
The simple answer: you are missing quotes around your string:
System.out.printf( "%s \n%s \n","Hi, my name is xxx.",
"I was born in xxx.");
The long answer: usually, you want the string argument to contain all
the text, with gaps for where the other stuff should come, and then
provide the other stuff.
System.out.printf("Hi, my name is %s%n, I was born in %s.%n", name,
birthPlace);
where name and birthPlace are variables pointing to your name and birth
place, respectively.
Note the use of %n instead of \n. %n is platform independent.
H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFFF6E0e+7xMGD3itQRAgMlAJsGBRqsS7uXuv2A+Lxj1zOmh9cjnwCfTjVs
QNRFo8dunLVXOX2m8F2ke8M=
=zBxP
-----END PGP SIGNATURE-----
.
- References:
- very new to java
- From: porky008
- very new to java
- Prev by Date: very new to java
- Next by Date: Re: very new to java
- Previous by thread: very new to java
- Next by thread: Re: very new to java
- Index(es):
Relevant Pages
|