Learning Outcome C Using Characters To Manipulate Data in Programs
Learning Outcome C Using Characters To Manipulate Data in Programs
Notes
(PPB115D/PPG115D/
PPBFD/PPGF15D)
Compiled by
V. Booi
All rights reserved. Apart from any fair dealing for the purpose of research
criticism or review as permitted under Copyright Act, no part of this
document may be reproduced or transmitted in any other form or by any
means, electronic
Learning outcome:or mechanical,
C.2. includingclasses
Using predefined photocopy and recording, without
in programs.
permission in writing from the publisher.
Learning Outcome C: Using characters to manipulate data in programs
In this learning unit, you are will be introduced to Java’s character methods.
The techniques discussed in this learning unit are for validating program input, displaying
information to users and other text based processing.
Characters
Characters are the fundamental building block of every java source program.
Every program contain a sequence of characters that are grouped together
meaningfully and they interpreted by the java compiler.
A program may contain character literals.
A character literal is an integer value represented as a character in single quotes.
This integer value is referred to as an ASCII code for a character.
1. isDigit () this method of the Character class and is used to determine if a character is a digit.
2. Write a program that will allow a user to enter a number of characters and an asterisk ( *) to
terminate the program. The program must determine in a static method called letterDigit()
if the character entered is a character or a digit and it must return a true if it is a letter or
digit or a false if it is not any of the above.