Java & J2EE Page 5 - The JSP Files (part 1): Purple Pigs In A Fruitbasket |
Just as you can create a variable to hold strings, you can create variables of other types too: int - used to store integers char - used to store a single character in Unicode format float and long - used to store floating-point numbers boolean - used to store "true" and "false" values (note that unlike languages like C and PHP, JSP does not recognize 1 => true and 0 => false) Let's take a simple example that adds two numbers and displays the result.
And the output is:
In this case, we've simply defined two variables as integer values, assigned values to them, and added them up to obtain the sum. In a similar vein, the next example demonstrates adding strings together:
And the output is:
In this case, the + operator is used to concatenate two strings together, which is then displayed via println().
blog comments powered by Disqus |