In the third part of the Java tutorial for beginners video series, we look at working with text using the String class. We also get our first real peek at using classes and objects.
Code for this tutorial:
public class Application {
public static void main(String[] args) {
int myInt = 7;
String text = "Hello";
String blank = " ";
String name = "Bob";
String greeting = text + blank + name;
System.out.println(greeting);
System.out.println("Hello" + " " + "Bob");
System.out.println("My integer is: " + myInt);
double myDouble = 7.8;
System.out.println("My number is: " + myDouble + ".");
}
}
Hello Bob Hello Bob My integer is: 7 My number is: 7.8.
Learn to program Java Swing with my complete video course – desktop programming and applets. Includes 7 free videos. Click here for details.
All pages on this site are copyright © 2013 John W. Purcell