#6 | Declaring Java Strings and using String literals | Learn Java
Автор: Neil Gillies
Загружено: 2023-09-01
Просмотров: 163
In this video we learn about String variables and String literals.
Here is the code used in this lesson:
public class Main {
public static void main(String[] args) {
String firstName = "Mary";
String surname = "MacPherson";
int houseNumber = 7;
String streetAddress = "Park Street";
String town = "Glasgow";
String postcode = "G12 45W";
System.out.println("Your name is " + firstName + " " + surname);
System.out.println("You live at " + houseNumber + " " + streetAddress);
System.out.println(town + " " + postcode);
}
}
Here is a copy of the lesson notes:
// Strings are a data type that allow you to store any text and characters, including "character representations" of numbers.
// For words, names, messages and so on, or combinations of text and numbers - e.g. vehicle registration, postcodes etc.
// You can't perform math operations on any "numbers" stored in a String (you'd need to store them as a numerical data type e.g. int).
// A String is actually a special type of data type and is technically considered a Java class.
// String literals are text values that are not stored within a variable - System.out.print("Hello World");
// You have to decide when best to use Strings and String literals - use a String if you think the value is liable to change.
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: