Re: very new to java



-----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-----
.



Relevant Pages

  • Re: How to swap two variable later?
    ... public string Second ... > Class "Swap" is construncted in "Main" with two initial> variables. ... > public class MyClass ... > public static void Main ...
    (microsoft.public.dotnet.languages.csharp)
  • help...
    ... public class Main { ... public static void main{ ... String name = JOptionPane.showMessageDialog(null, "Hello world: ...
    (comp.lang.java.beans)
  • Date different
    ... How to Calculate Date diff? ... public class Dir_t { ... Dir_t (String path) { ... public static void main { ...
    (comp.lang.java.programmer)
  • Dir filter how to set ?
    ... public class Dir { ... Dir (String path) { ... public static void main { ...
    (comp.unix.programmer)
  • How to use Log4net TelnetAppender and Trace Listeners
    ... Is there a way to use Log4net and Trace Listeners? ... public static void Initialize(string traceListeners, ... public static void Flush2File(string file, string msg, bool ...
    (microsoft.public.dotnet.framework)