Description: Introduction to the fundamentals of Java. In this session, we discuss several principles of programming such as data types (primitives and object), variables, and how Java recognizes them in memory. How to use the API library, in particular the Math Library, and finally String. How to perform concatenation and other basic methods that are in the String object.
ACM CCECC
[Variables and Literals]
PL-05. Implement algorithms that utilize immutable and mutable variables.
AR-04. Examine the internal representation of non-numeric data.
[Primitive Data Types]
CYB-16. Explain the tradeoffs of developing a program in a type-safe language.
PL-10. Explain the security implications of a type-safe language for software development.
AR-05. Compare different methods for converting numerical data from one format to another.
AP CS A
[Variables and Literals]
VAR-1.A Create string literals.
VAR-1.A.1 A string literal is enclosed in double quotes.
VAR-1.C.2 Each variable has associated memory that is used to hold its value.
VAR-1.C.3 The memory associated with a variable of a primitive type holds an actual primitive value.
VAR-1.C.4 When a variable is declared final, its value cannot be changed once it is initialized.
VAR-1.G Explain where variables can be used in the program code.
CON-1.A.1 A literal is the source code representation of a fixed value.
[Primitive Data Types]
VAR-1.B Identify the most appropriate data type category for a particular specification.
VAR-1.B.1 A type is a set of values (a domain) and a set of operations on them.
VAR-1.B.2 Data types can be categorized as either primitive or reference.
VAR-1.B.3 The primitive data types used in this course define the set of operations for numbers and Boolean values.
VAR-1.C Declare variables of the correct types to represent primitive data.
VAR-1.C.1 The three primitive data types used in this course are int, double, and boolean.
CON-1.C.4 Values of type double can be rounded to the nearest integer by (int)(x + 0.5) or (int)(x – 0.5) for negative numbers.
CON-1.C.5 Integer values in Java are represented by values of type int, which are stored using a finite amount (4 bytes) of memory. Therefore, an int value must be in the range from Integer.MIN_VALUE to Integer.MAX_VALUE inclusive.
CON-1.C.6 If an expression would evaluate to an int value outside of the allowed range, an integer overflow occurs. This could result in an incorrect value within the allowed range.
[The String Class]
VAR-1.E For String class— a. Create String objects b. Call String methods;
VAR-1.E.1 String objects can be created by using string literals or by calling the String class constructor.
VAR-1.E.2 String objects are immutable, meaning that String methods do not change the String object.
VAR-1.E.3 String objects can be concatenated using the + or += operator, resulting in a new String object.
VAR-1.E.4 Primitive values can be concatenated with a String object. This causes implicit conversion of the values to String objects.
VAR-1.E.5 Escape sequences start with a \ and have a special meaning in Java. Escape sequences used in this course include \”, \\, and \n.
VAR-1.E.9 The String class is part of the java.lang package. Classes in the java.lang package are available by default.
VAR-1.E.10 A String object has index values from 0 to length – 1. Attempting to access indices outside this range will result in an IndexOutOfBoundsException.
VAR-1.E.11 A String object can be concatenated with an object reference, which implicitly calls the referenced object’s toString method.
VAR-1.E.12 The following String methods and constructors—including what they do and when they are used—are part of the Java Quick Reference— ● String(String str) —Constructs a new String object that represents the same sequence of characters as str ● int length()—returns the number of characters in a String object ● String substring(int from, int to)—returns the substring beginning at index from and ending at index to – 1 ● String substring(int from) —returns substring(from, length()) ● int indexOf(String str) —returns the index of the first occurrence of str; returns -1 if not found ● boolean equals(String other) —returns true if this is equal to other; returns false otherwise ● int compareTo(String other) —returns a value < 0 if this is less than other; returns zero if this is equal to other; returns a value > 0 if this is greater than other
VAR-1.E.13 A string identical to the single element substring at position index can be created by calling substring(index, index + 1).
CS1
[Variables and Literals]
[Primitive Data Types]
130.421.c.4.d Identify the data types and objects needed to solve a problem;
130.421.c.6.l Understand the binary representation of numeric and non-numeric data in computer systems;
130.421.c.6.m Understand the finite limits of numeric data;
130.421.c.6.o Choose, identify, and use the appropriate data types for integer, real, and Boolean data when writing program solutions;
130.421.c.6.u Choose, identify, and use the appropriate data type and structure to properly represent the data in a program problem solution;
130.421.c.6.v Compare and contrast strongly typed and un-typed programming languages;
[The String Class]
130.421.c.6.r Demonstrate an understanding of how to represent and manipulate text data, including concatenation and other string functions;
Description: Introduction to the arithmetic possibilities that Java has to offer. In this video, we explore the applications of those operations and some of the libraries that the programming language offers to allow us to code more efficiently.
Description: Introduction to the concepts of User Interaction in Java. In this session, we discuss the meaning and uses of the Scanner, arguments, and JOptionPane to create Graphical User Interfaces (GUIs). How to interact with the computer user using Java. Demonstration of Scanner and JOptionPane (Please notice that the JDK 8 does not support JOptionPane operations, but the 11th version does). Demonstration of data type handlers and wrappers such as Integer.parseInt().
Code:
ACM CCECC
[Scope, Comments, and Programming Style]
SDF-18. Apply consistent documentation and program style standards.
[Keyboard Input and Dialog Boxes]
HCI-04. Write a simple application that uses a modern graphical user interface.
AP CS A
[Scope, Comments, and Programming Style]
MOD-2.C Describe the functionality and use of program code through comments.
MOD-2.C.1 Comments are ignored by the compiler and are not executed when the program is run.
MOD-2.C.2 Three types of comments in Java include /* */, which generates a block of comments, //, which generates a comment on one line, and /** */, which are Javadoc comments and are used to create API documentation.
CS1
[Scope, Comments, and Programming Style]
130.421.c.2.d Write programs with proper programming style to enhance the readability and functionality of the code by using meaningful descriptive identifiers, internal comments, white space, spacing, indentation, and a standardized program style;
130.421.c.6.s Demonstrate an understanding of the concept of scope;
[Keyboard Input and Dialog Boxes]
130.421.c.2.b Create interactive console display interfaces, with appropriate user prompts, to acquire data from a user;
130.421.c.2.c Use Graphical User Interfaces (GUIs) to create interactive interfaces to acquire data from a user and display program results;