02-java-basic-concepts

02-java-basic-concepts - Java Programming: Basic Concepts...

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

View Full Document Right Arrow Icon
Java Programming: Basic Concepts CSE 110: Introduction to Computer Science 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
Outline of Topics Basic output Variables Types and declarations Assignment and initialization Basic arithmetic Basic input with Scanner 2
Background image of page 2
Console Output Use System.out.print() Text to be printed goes in double quotes inside the parentheses: System.out.print(“Hello, world!”); Output string is printed verbatim! System.out.println() goes to the next line 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
Variables Used to store information for later use Different types for different kinds of data: int stores integers char stores single characters (‘a’) Foat and double store decimal values String stores character sequences (in quotes) 4
Background image of page 4
Declarations Declare a variable (tell the compiler that you’re going to use it) by writing the type, followed by the name: int x; // x can hold integers double pi; // can be decimal 5
Background image of page 5

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

View Full DocumentRight Arrow Icon
in Variables Use a single ‘=’ to store a value in a variable The name on the left gets the value on the right side: x = 5; // Stores 5 in x
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/29/2012 for the course CSE 110 taught by Professor Shaunakpawagi during the Spring '08 term at SUNY Stony Brook.

Page1 / 12

02-java-basic-concepts - Java Programming: Basic Concepts...

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

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