Output with Print— Strings

Lesson Details:
July 10, 2020


I: Introduction

A: What is a programming language?

Coding languages are forms of communication that allow users to instruct computers how to perform tasks. Users of computer systems are categorized in two groups, system owners and operators, who are responsible for the maintenance of the computer system.System owners are responsible for the purchase of new hardware and software, installation of equipment, training of users, upgrade of equipment, etc. Operators are responsible for the day-to-day operations of the computer systems.

B: Comparing programming languages

A number of programming languages exist in the market today. Some have been in the market for many years while others are relatively new. One similarity among all programming languages is that they are used for writing instructions in code language that allows computers to understand them. The most popular programming language is Java, which began in 1995 with the release of JDK 1.0. This language has become widely accepted with its syntax similar to C++. However, C++ is still used by many programmers worldwide, especially by students who wish to learn more about programming.

II: Body

A: Output with print

The output statement with the keyword print outputs data on standard output device(s) or any other object that can be written to. The print statement is commonly used within programs through print statements to display information about variables or program results on screen.

Printing is usually terminated by pressing the Enter key. However, this varies from platform to platform and type to type.

B: Strings

The string class is used to represent strings of text within a program. It’s one of the simplest classes in Java that is used to define character strings and associated methods to manipulate them. String objects store a sequence of characters and therefore it's not necessary to specify the length of a string when creating an instance. These types of objects can be created using the static valueOf method, which returns a string object whose value is equal to the argument passed in, or by invoking the constructor directly. String objects can also be concatenated using + operator, which returns a new string object by concatenating two strings together. Also, accesses to individual characters in a string can be performed using charAt() method or subscript operator []. Both methods return individual characters from a string object, while subscript operator [], returns only one character from a string object and throws an exception if index is outside bounds of the string.

loader
Course content