Specifications

Sun Services
Java™ Programming Language
Module 3, slide 19 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Variables, Declarations, and
Assignments
1 public class Assign {
2 public static void main (String args []) {
3 // declare integer variables
4 int x, y;
5 // declare and assign floating point
6 float z = 3.414f;
7 // declare and assign double
8 double w = 3.1415;
9 // declare and assign boolean
10 boolean truth = true;
11 // declare character variable
12 char c;
13 // declare String variable
14 String str;
15 // declare and assign String variable
16 String str1 = "bye";
17 // assign value to char variable
18 c = 'A';
19 // assign value to String variable
20 str = "Hi out there!";
21 // assign values to int variables
22 x = 6;
23 y = 1000;
24 }
25 }