Java Identifiers

Java Identifiers - OR import java.util.*; //to import all...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Java identifiers (e.g., variable names) Java identifiers consist of letters, digit, under score _ , and dollar sign $. They cannot begin with a digit. Java API (Application Programmer Interfaces) Specification -- It contains the list of all pre-defined Java classes in the Java libraries. (There is a link to API Specification from the course web site -> notes -> Java API Specification) API contains packages, and each packages contain classes. Examples of packages: java.lang package, java.util package, etc. java.lang package contains the String class, the System class, and so on. Notes: java.lang is always imported without an "import" statement. However, to use a class in any other package, you need to import it. import java.util.Scanner;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: OR import java.util.*; //to import all classes in this package System.out System.out is a destination (object) to which we can send output. Commonly used methods are "print" and "println". In order to print out "Hello World" in a console, we can use a code: System.out.print("Hello World"); You can print out a primitive data type using "print" method as well as strings. To concatenate a string with a string, or a primitive data, you can use "+". For instance, int number = 10; System.out.print("The number is " + number); "println" method adds a carriage return at the end. Thus System.out.print("Hello World\n"); and System.out.println("Hello World"); will give the same result....
View Full Document

This note was uploaded on 09/25/2010 for the course CSE 71682 taught by Professor Nakamura during the Spring '10 term at ASU.

Page1 / 2

Java Identifiers - OR import java.util.*; //to import all...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online