Identifiers.

Slides:



Advertisements
Similar presentations
Programming with Java. Problem Solving The purpose of writing a program is to solve a problem The general steps in problem solving are: –Understand the.
Advertisements

1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Chapter 1: Introduction
LESSON 3 - Identifiers JAVA PROGRAMMING. Identifiers All the Java components —classes, variables, and methods— need names. In Java these names are called.
The Java Programming Language
JAVA PROGRAMING LANGUAGE. Content of Java 2 SDK  Development Tools (In the bin subdirectory.) Tools and utilities that will help you develop, execute,
Outline Java program structure Basic program elements
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Java Building Elements Lecture 2 Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University
Java Language and SW Dev’t
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
C Tokens Identifiers Keywords Constants Operators Special symbols.
Java Fundamentals Asserting Java Chapter 2: Introduction to Computer Science ©Rick Mercer.
© 2006 Pearson Education 1 Obj: cont 1.3 and 1.4, to become familiar with identifiers and to understand how programming languages work HW: p.51 #1.8 –
CPS120: Introduction to Computer Science Variables and Constants Lecture 8 - B.
The Java Programming Language
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Chapter 4 Procedural Methods. Learning Java through Alice © Daly and Wrigley Objectives Identify classes, objects, and methods. Identify the difference.
CPS120: Introduction to Computer Science
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Java Syntax and Style JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin, Gary Litvin,
Chapter 2: Java Fundamentals
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
Java The Java programming language was created by Sun Microsystems, Inc. It was introduced in 1995 and it's popularity has grown quickly since A programming.
SE-1010 Dr. Mark L. Hornick 1 Variables & Datatypes.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
Copyright Curt Hill Variables What are they? Why do we need them?
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
Ajmer Singh PGT(IP) Programming Fundamentals. Ajmer Singh PGT(IP) Java Character Set Character set is a set of valid characters that a language can recognize.
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
CSM-Java Programming-I Spring,2005 Fundamental Data Types Lesson - 2.
CPS120: Introduction to Computer Science Variables and Constants.
Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
COP 2551 Introduction to Object Oriented Programming with Java Topics –Introduction to the Java language –Code Commenting –Java Program Structure –Identifiers.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 1: Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science.
Introduction to Java Programming by Laurie Murphy Revised 09/08/2016.
The Essentials of a Java Program JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin,
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
Working with Java.
Chapter 3 GC 101 Java Fundamentals.
Chapter 2 Elementary Programming
Data Types, Identifiers, and Expressions
University of Central Florida COP 3330 Object Oriented Programming
Data types and variables
Java Programming: From Problem Analysis to Program Design, 4e
Chapter 4 Procedural Methods.
Statements, Comments & Simple Arithmetic
مساق: خوارزميات ومبادئ البرمجة الفصل الدراسي الثاني 2016/2015
Introduction to Java Programming
An Introduction to Java – Part I, language basics
Chapter 1: Computer Systems
Units with – James tedder
Units with – James tedder
Chapter 7 Procedural Methods.
Expressions and Assignment
Anatomy of a Java Program
Programming Language C Language.
Primitive Types and Expressions
Chap 2. Identifiers, Keywords, and Types
Use a variable to store a value that you want to use at a later time
Lexical Elements & Operators
Presentation transcript:

Identifiers

Introduction An identifier is a collection of certain characters that could mean a variety of things There are some existing Java identifiers sqrt String Integer System in out We can make up new identifiers test1 x1 aNumber MAXIMUM A_1

Identifiers

Valid Identifiers Identifiers have from 1 to many characters: 'a'. .'z', 'A'..'Z', '0'..'9', '_', $ Identifiers start with letter a1 is legal, 1a is not can also start with underscore or dollar sign: _ $ Java is case sensitive. A and a are different.

Reserved Identifier Reserved identifier: An identifier with a pre-defined meaning that can not be changed Java reserved identifiers not a complete list boolean default for new break do if private case double import public catch else instanceOf return char extends int void class float long while

Identifiers Names given to variables, objects, methods Must not be a Java keyword See Appendix B for list of keywords May begin with a letter or the underline character _ Followed by any number of characters, digits, or _ (note, no blanks) Identifiers should be well chosen use complete words (even phrases) this helps program documentation

Conventions for Identifiers Classes Names given in lowercase except for first letter of each word in the name Variables Same as classes, except first letter is lowercase Constants All caps with _ between words Methods like variable names but followed by parentheses

Identifiers Keywords Lexical elements (or identifiers) that have a special, predefined meaning in the language Cannot be redefined or used in any other way in a program Ex: public, private, if, class, throws See p. 32 in LL for complete list

Identifiers Other Identifiers Defined by programmer Java API defines quite a few for us e.g. System, Scanner, String, out are used to represent names of variables, methods and classes Cannot be keywords We could redefine those defined in Java API if we wanted to, but this is generally not a good idea Java IDs must begin with a letter, followed by any number of letters, digits, _ (underscore) or $ characters Similar to identifier rules in most programming languages

Example for Java Identifiers package javaidentifiers; /** * * @author paul */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args)

Program { // TODO code application logic here System.out.println(“Must start with a letter, ($), or connecting character (_)”); System.out.println(“Can not start with a number”); System.out.println(“No limits to the amount of characters for a identifier”);

Program System.out.println(“You can not use a Java Keyword”); System.out.println(“Case sensitive – IDENTIFER is different from identifier”); System.out.println(“Legal – see code”); int _$a; int x; int $j; int _____iiii;

Program System.out.println(“Illegal”); System.out.println(“int :6 – breaks rule 1″); System.out.println(“int ;J – breaks rule 1″); System.out.println(“int 6pp – breaks rule 2″); System.out.println(“int else – breaks rule 4″); }

The End ….. Thank You …..