Identifiers<br />www.ustudy.in<br />
Introduction<br /><ul><li>An identifier is a collection of certain characters that could mean a variety of things
There are some existing Java identifiers  </li></ul>sqrt  String  Integer  System  in  out<br /><ul><li>We can make up new...
Identifiers<br />www.ustudy.in<br />
Valid Identifiers<br /><ul><li>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.</li></ul>www.ustudy.in<br />
Reserved Identifier<br /><ul><li>Reserved identifier: Anidentifier with a pre-defined meaning that can not be changed
Java reserved identifiers not a complete list</li></ul>boolean		default		for		new<br />   break		do		if		private<br />   c...
Identifiers<br /><ul><li>Names given to variables, objects, methods
Must not be a Java keyword
See Appendix B for list of keywords
Upcoming SlideShare
Loading in …5
×

Identifiers

652 views

Published on

This Presentation has the details about Identifiers in JAVA

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
652
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Identifiers

  1. 1. Identifiers<br />www.ustudy.in<br />
  2. 2. Introduction<br /><ul><li>An identifier is a collection of certain characters that could mean a variety of things
  3. 3. There are some existing Java identifiers </li></ul>sqrt String Integer System in out<br /><ul><li>We can make up new identifiers </li></ul> test1 x1 aNumber MAXIMUM A_1<br />www.ustudy.in<br />
  4. 4. Identifiers<br />www.ustudy.in<br />
  5. 5. Valid Identifiers<br /><ul><li>Identifiers have from 1 to many characters:
  6. 6. 'a'. .'z', 'A'..'Z', '0'..'9', '_', $
  7. 7. Identifiers start with letter a1 is legal, 1a is not
  8. 8. can also start with underscore or dollar sign: _ $
  9. 9. Java is case sensitive. A and a are different.</li></ul>www.ustudy.in<br />
  10. 10. Reserved Identifier<br /><ul><li>Reserved identifier: Anidentifier with a pre-defined meaning that can not be changed
  11. 11. Java reserved identifiers not a complete list</li></ul>boolean default for new<br /> break do if private<br /> case double import public<br /> catch else instanceOf return<br /> char extends int void<br /> class float long while<br />www.ustudy.in<br />
  12. 12. Identifiers<br /><ul><li>Names given to variables, objects, methods
  13. 13. Must not be a Java keyword
  14. 14. See Appendix B for list of keywords
  15. 15. May begin with a letter or the underline character _
  16. 16. Followed by any number of characters, digits, or _ (note, no blanks)
  17. 17. Identifiers should be well chosen
  18. 18. use complete words (even phrases)
  19. 19. this helps program documentation</li></ul>www.ustudy.in<br />
  20. 20. Conventions for Identifiers<br />Classes<br /><ul><li>Names given in lowercase except for first letter of each word in the name</li></ul>Variables<br /><ul><li>Same as classes, except first letter is lowercase</li></ul>Constants<br /><ul><li>All caps with _ between words</li></ul>Methods<br /><ul><li>like variable names but followed by parentheses</li></ul>www.ustudy.in<br />
  21. 21. Identifiers<br />Keywords<br /><ul><li>Lexical elements (or identifiers) that have a special, predefined meaning in the language
  22. 22. Cannot be redefined or used in any other way in a program
  23. 23. Ex: public, private, if, class, throws
  24. 24. See p. 32 in LL for complete list</li></ul>www.ustudy.in<br />
  25. 25. Identifiers<br />Other Identifiers<br /><ul><li>Defined by programmer
  26. 26. Java API defines quite a few for us
  27. 27. e.g. System, Scanner, String, out
  28. 28. are used to represent names of variables, methods and classes
  29. 29. Cannot be keywords
  30. 30. We could redefine those defined in Java API if we wanted to, but this is generally not a good idea
  31. 31. Java IDs must begin with a letter, followed by any number of letters, digits, _ (underscore) or $ characters
  32. 32. Similar to identifier rules in most programming languages</li></ul>www.ustudy.in<br />
  33. 33. Example for Java Identifiers<br />package javaidentifiers;<br />/**** @author paul*/public class Main <br />{<br /> /** * @param args the command line arguments */ public static void main(String[] args)<br />www.ustudy.in<br />
  34. 34. Program<br /> { // 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”);<br />www.ustudy.in<br />
  35. 35. Program<br /> 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”);<br /> int _$a; int x; int $j; int _____iiii;<br />www.ustudy.in<br />
  36. 36. Program<br /> 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″);<br /> }<br />}<br />www.ustudy.in<br />
  37. 37. The End<br /> ….. Thank You …..<br />www.ustudy.in<br />

×