chapter 1- variables and datatypes
Just like we have some rules that we follow to speak English(grammar), we have some rules to follow while writing a java program. The set of these rules is called syntax( vocabulary and grammar of java ). Variables The variable is a container that stores a value. This value can be changed during the execution of the program. Example: int number = 8; here, int is a data type , the number is the variable name and 8 is the value it stores Rules for declaring a variable name we can choose a name by declaring a java variable if the following rules are followed: 1. Must not begin with a number ==>int 1arry; is invalid! 2. Name is case sensitive ==>dhruv and Dhruv are different! 3. Should not be a keyword( like void). 4. white space is not allowed. ==>int developer dhruv is invalid. 5. Can contain alphabets, $ character _ character, and digits if the other conditions are met. Data types Data types in java fall under the following categories. 1.Pr...