Java for Android 1

Listing 1-1. Saying Hello in a Java Language Context
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello, World!");
}
}
=========================================================
Listing 1-2. Dumping Command-Line Arguments Stored in main()’s args Array to the Standard Output Stream
public class DumpArgs
{
public static void main(String[] args)
{
System.out.println("Passed arguments:");
for (int i = 0; i < args.length; i++) //12 CHAPTER 1: Getting Started with Java
System.out.println(args[i]);
}
}

==========================================================

Listing 1-3. Echoing Text Read from Standard Input to Standard Output
public class EchoText
{
public static void main(String[] args)
{
boolean isRedirect = false;
if (args.length != 0)
isRedirect = true;
int ch;
try
{
while ((ch = System.in.read()) != ((isRedirect) ? -1 : '\n'))
System.out.print((char) ch);
}
catch (java.io.IOException ioe)
{
System.err.println("I/O error");
}
System.out.println();
}
}
===============================================================