Udjuni.com

udjuni.com search:




Java variables and data types


A variable is defined as a named piece of memory that a java program uses to store data. Each of these storage pieces can only store data of a certain type. In other words, if you defined as variable of type integer, that variable can only hold integer values. Thus, if you tried to save a value such as 0.67 into that memory space, that value might be saved as zero or it might be converted to the nearest integer before it is saved. In any case, that value will not be saved as it is.

Naming Variables


You, the developer can choose to name your variables anything you want. The name of a variable in java is called an identifier and such a name must start with a letter, underscore or a dollar sign ($). The rest of other characters are illegal and will generate compile errors. Additional restrictions include not using java keywords as variable names or a literal or anything that could be interpreted as a constant value.

Variable declaration and data types


Defining a variable in java involves specifying the variable and data type. For example, we define integer variables as follows:
 int numberOfTries; 
in this example, int tells the interpreter that the variable being declared is of type integer and then assigns a name numberOfTries. Each java statement ends with a semicolon. Variables can be numeric such as integer, floating point number; strings and Dates and time variables. To define a character variable you use the following syntax:
 char firstName = “Mukoya”; 

This statement defines a variable of type character and then assigns the name to that variable. In layman terms, this means storing the characters “Mukoya” in the memory space named firstName.


RELATED ARTICLES:


Introduction to Java programming
Computer program as we learned in the posting Introduction to Programming

Starting to program in Java
Most java developers would describe it as an innovative programming language that enables a developer to write what is called "Applets" or pieces of java code that can be embedded in web pages. In addition to this benefit, compiled java code can be run on a variety of

Compiling and executing a java program
Java source code is always stored in a file with a .java file extension. Once you have created your source code, you simply save it with a .java extension and it is ready to be compiled. To compile your java code, you use the f

Common SQL Data types
Now that you have identified your data entities or tables, you have to define each attribute of the tables you have identified. These definitions include the name of the attribute and the type of data that can be stored in the field. Most relational database systems have a number of data types that

PHP Variables
Variables In PHP, unlike other programming languages you can declare a variable or allocate variable storage space without worrying about the type of data that will be stored in it. Thus values are used when data in your script becomes available and can change during the lifetime o

Solving linear equations with two variables
In the last posting titled "Basic Linear equations", we covered the basics of solving an equation with one "unknown". There are rules that govern linear equations that we did not cover in the last posting. I will be covering those rules here before we move on to linear equations with two unkn

Exponents of Variables


Of Variables


Selecting data from multiple tables
So far we have covered methods of retrieving data from single table. In real life however, you hardly get to only retrieve data from one table. In other words, to retrieve and interpret information, you normally get such information from different tables each of which will contain only information a

Updating and deleting data with SQL
In the posting “Introduction to SQL”, we covered the creation of data storage space or database and its entities. We then went a little further to cover a methods of entering data into those entities or tables and methods of retrieval. There are however, times when the data stored in

Did not find it? Try udjuni.com search:







© 2009 UdjunI LLC. All rights reserved | Privacy policy | Tutorial Index | RSS Feed