Library Methods
Learning Objectives
In addition to all previous competencies, upon completion of this unit, you should be able to:
- Understand and use some common library methods
- Convert a
Stringvariable into an number variable - Understand and accomplish end-user validation
- Understand and use the Scanner "has" methods
- Understand and properly compare strings
- Understand and properly compare numbers
Learning Activities
In this unit, you will learn about common library methods and the benefits of using them. You will learn strategies for accepting end-user input and validating the input to meet the requirements of the application. You will learn to safely convert String variables into numbers. The techniques learned in these chapters are fundamental techniques built into the programming language. You can use these techniques to create complex applications. Each link below takes you to a specific chapter within this unit.
“The will to win, the desire to succeed, the urge to reach your full potential... these are the keys that will unlock the door to personal excellence.” -Confucius
- Library Methods
- What are Library Methods?
- Using Library Methods
- Java Library Methods
- The Dot Operator
- What You Learned
- Common String Methods
- String.toLowerCase()
- String.toUpperCase()
- String.length()
- String.substring()
- String.contains()
- Comparing Strings
- What You Learned
- Common Number Methods
- Parsing a String into a Number
- Input Mismatch Exception
- Math Library Methods
- Math.random()
- Math.round()
- Math.min() and Math.max()
- Comparing Numbers
- What You Learned
- Common Print Methods
- Requesting Information from the End-user
- System.out.println()
- System.out.print()
- System.out.printf()
- What You Learned
- Scanner Library Methods
- The Scanner Class
- Scanner Methods that Return a String
- .next()
- .nextLine()
- Scanner Methods that Return a Number
- .nextDouble()
- .nextInt()
- Scanner Methods that Return a Boolean
- .hasNextDouble()
- .hasNextInt()
- End-user Input Validation
- What You Learned