Wednesday, January 11, 2012

The switch statement in JAVA

A switch statement provide you the option to test for a range of values for your variables. Switch statement helps simplifying multiple choices in a program

Syntax of Switch statement

switch(expression)

{

case value-1:Statement 1

break;

case value-2:Statement 2

break;

.........

.........

default: default Statement 3

break;

}

statement-x;

switch

The switch keyword is followed by a parenthesized integer expression. The switch statement executes the case corresponding to the value of the expression. Normally the code in a case clause ends with a break statement, which exits the switch statement and continues with the statement following the switch. If there is no corresponding case value, the default clause is executed. If no case matched and there is no default clause, execution continues after the end of the switch statement.

case

The case keyword is followed by an integer constant and a colon. This begins the statements that are executed when the switch expression has that case value.

default
If no case value matches the switch expression value, execution continues at the default clause.

break

The break statement causes execution to exit to the statement after the end of the switch. If there is no break, execution flows into the next case.

For more information visit http://www.programming-training.com/decision.html

Wednesday, January 4, 2012

If Statement in JAVA



If else statement is used to execute some code only if a specified condition is true.If condition is true then the statement will be execute 

Syntax of  If Statement in JAVA

if (condition)
  {
  code to be executed if condition is true
  }

Note : if is written in only lowercase letters. If we use uppercase letter like (IF) it will give error 


Example of if statement

public class IfStatement {

 public static void main(String[] args) {
  int a = 20, b = 30;
  if (a > b)
   System.out.println("a > b");
  if (a < b)
   System.out.println("b > a");
 }
}


Output of This Example

b > a


Sunday, December 25, 2011

operator in JAVA

An operator is a symbol that tell the computer to perform certain mathematical or logical manipulation.

Java operators are divided into eight categories: assignment, arithmetic, relational, logical, bitwise,
compound assignment, conditional, and type
.


 Assignment Operators         =
 Arithmetic Operators         -        +        *        /        %        ++        --
 Relational Operators         >        <        >=        <=        ==        !=
Logical Operators && || & | ! ^ Bit wise Operator & | ^ >> >>> Compound Assignment Operators += -= *= /= %=
         <<=        >>=     >>>=
 Conditional Operator         ?:
 
For more information visit programming-training.com 

Wednesday, December 21, 2011

Integer Constants in JAVA

An integer constant refers to a sequence of digits.Their are three types of integer

* Decimal Integer

Decimal integer consist of set of digit, 0 through 9. Example of decimal integer constants are: 156          -321      0       45689

Note : Embeded spaces, commas, and non-digit character are not permited between digits.

# Octal Integers

An octal integer constant consist of any combination of any combination of digit from 0 through 7, with a leading 0.Example of octal integer are:038         0        0564        06891

* Hexadecimal integer

A sequence of digit preceeded by 0x or 0x is considered as hexadecimal integer.In that include alphabets A through F or a through f.Example of hexadecimal integer is0x2       0x9F       0xbcd        0x









Example of Java Constant 

class IntConstant
{
public static void main(string args[])
{
int i=10;
System.out.println("Integer Contant Values : " +i);
}
}


Output of a Programme

Integer Contant Values : 10

Sunday, December 18, 2011

PHP History


PHP's structure is heavily influenced by the C programming language, a general-purpose language that has existed since 1978 and has been used to develop many large programs, including UNIX and Microsoft Windows. C's popularity led many subsequent languages to use its same general syntax, so that programmers familiar with C would quickly feel comfortable using the new language instead. Other C-based languages include C++, Java, Perl, JavaScript, and C#. Of course, all are fairly distinct languages, but since all of these languages have a similar core, you will find them fairly familiar after seeing PHP.

PHP development is continuing, as those on the PHP team refine the language to enhance its security, to facilitate development of large-scale Web sites, and provide other new features. As of mid-2007, when this was written, the current official version of PHP is version 5, although version 6 is nearing completion. Version 4 is still in wide use, partially because people haven't gotten around to installing the newer versions — but also because established Web sites need to take issues like security and reliability very seriously, and version 4 is a more thoroughly tested software package

Friday, December 16, 2011

History of C++

The history of C++ begins with C. C++ is built upon the foundation of C. Thus, C++ is a superset of C. C++ expanded and enhanced the C language to support object-oriented programming (which is described later in this module). C++ also added several other improvements to the C language, including an extended set of library routines.

C++ was invented by Bjarne Stroustrup in 1979, at Bell Laboratories in Murray Hill, New Jersey. He initially called the new language “C with Classes ” However in 1983 the name was changed to C++ Stroustrup built C++ on the foundation of C including all of C's features attributes and benefits

Wednesday, December 14, 2011

Primitive Data Types

The Java programming language is statically-typed, which means that all variables must first be declared before they can be used.

  • byte: The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation.
  • short: The short data type is a 16-bit signed two's complement integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive). As with byte, the same guidelines apply: you can use a short to save memory in large arrays, in situations where the memory savings actually matters.
  • int: The int data type is a 32-bit signed two's complement integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). For integral values, this data type is generally the default choice unless there is a reason (like the above) to choose something else. This data type will most likely be large enough for the numbers your program will use, but if you need a wider range of values, use long instead.
  • long: The long data type is a 64-bit signed two's complement integer. It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive). Use this data type when you need a range of values wider than those provided by int.
  • float: The float data type is a single-precision 32-bit IEEE 754 floating point.
  • double: The double data type is a double-precision 64-bit IEEE 754 floating point.
  • boolean: The boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. This data type represents one bit of information, but its "size" isn't something that's precisely defined.
  • char: The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive).

    Variable in JAVA

Tuesday, December 13, 2011

Java Identifiers

In java there are several points to remember about identifiers. They are as follows:
  • All identifiers should begin with a letter (A to Z or a to z ), currency character ($) or an underscore (-).
  • After the first character identifiers can have any combination of characters.
  • A key word cannot be used as an identifier.
  • Most importantly identifiers are case sensitive.
  • Examples of legal identifiers:age, $salary, _value, __1_value
  • Examples of illegal identifiers : 123abc, -salary






Sunday, November 20, 2011

if...else Statement in JAVA

The syntax of if.....else statement

if(test expression)
{
True-block statements(s)
}
else{
false-block statement(s)
}
statement-x

 Decision making Java

Sunday, October 2, 2011

Simple Java programme

A Simple Java Programme
class SamplePro
{
public static void main(String args[])
{
System.out.println("Simple Java Example");
}
}

 In the above example class is keyword and the SamplePro is file name.

For more information about this example visit Learn java with example




Friday, September 24, 2010

Introduction of JAVA

Java is a programming language developed by James Gosling from Sun Microsystems in 1991. The first public version of Java (Java 1.0) was released 1995. Over time several various version of Java were available which improved and enhanced the language and it libraries as well as classes.
From the Java programming language the Java platform evolved. The Java platform allows that Code is written in other languages then the Java programming language and still runs on the Java virtual machine.

Characteristics of Java

Java has the following properties
  • Platform independentJava program do in general not access directly system resources but use the Java virtual machine as abstraction. This makes Java programs highly portable. A Java program which is standard complaint and follows certain rules can run unmodified all several platforms, e.g. Windows or Linux.
  • Object-orientated programming languageExcept the primitive data types, all elements in Java are objects
  • Strongly-typed programming language Java is strongly-typed, e.g. types of the elements must be pre-defined and conversion to other objects is relatively restricted.
  • Interpreted and compiled language Java source code is transfered into byte-code which does not depend on the target platform. This byte-code will be interpreted by the Java Virtual machine (JVM). The JVM contains a so called Hotspot-Compiler which translates critical byte-code into native code.
  • Automatic memory managementJava manages the memory allocation and de-allocation for creating new objects. The program does not have direct access to the memory. The so-called garbage collector deletes automatically object to which no active pointer exists.
  • Java is case sensitiveThe Java syntax is similar to C++. Java is case sensitive, e.g. the variables myValue and myvalue will be treated as different variables.

Tuesday, September 7, 2010

Few essential tips before begin with java

Learning the Java platform is an exciting journey. There is so much you can do with Java technologie but one biggest problem is that what you want to do and where to start is the first problem you need to sort out. The journey of learning Java platform should be fun, clear, and exciting one.


Before learning you need to consider the following points first
  • Choosing the tool
For learning java their are various tools are available like


javac The compiler for the Java programming language.
java The launcher for Java applications. In this release, a single launcher is used both for development and deployment.

The old deployment launcher, jre , is no longer provided.
javadoc API documentation generator
apt Annotation processing tool.
appletviewer Run and debug applets without a web browser.
jar Create and manage Java Archive (JAR) files.
jdb The Java Debugger.
javah C header and stub generator. Used to write native methods.
javap Class file disassembler
extcheck Utility to detect Jar conflicts.

First of all you will decide which tool to start for learning java .This is depending upon what you currently know about the tool. After reading about the tools, you will find out resources to learn about the technologies, and the details of the Java programming language.
The tools express the relationships between objects and how to make those objects interact and do things. Yet, each tool has been designed with a certain audience in mind.
  • Java Standard Edition (Java SE)
For learning the any tool you need the Java Standard Edition (Java SE) .Once you installed the Java SE on your computer, you are ready to learn the various tools that you want to learn.


Many of you, yet, may know some programming like C and C++ , or another programming language, or maybe you don’t know nothing of the programming language but you want to learn the programming language.


Download JAVA SE


After installing the Java SE , you'll also need to learn the basics of the Java programming language. Your best resource for this is The Java Tutorial.


After reading this article your all basic doubts will be sort out.