Tuesday, November 30, 2010

how can i create variable in java !!!

well creating variables in java is extremely easy like all other programming languages....................................................
integers can be created as

int data;
int data=5;
int data,result,sum;

long can be created as

long data;
long data=14.0;
long data,result,sum;

float can be 
float data; 
float data=4F;                  //this statment will execute as well and will convert 4 to float 4. this is called literals.
float data,result,sum;



double can be

double data;
double data=10D;        //this statment will execute as well and will convert 4 to double 4. this is called literals.
double data,result,sum;
characters can be created as
char data;
char data='k';
String could be created as
String data;
String data="hi ! this is java programme";

Statments type

Java has many different types of statements. Some statements simply create
variables that you can use to store data. These types of statements are often
called declaration statements, and tend to look like this:
int i;
String s = “This is a string”;
Customer c = new Customer();

Another common type of statement is an expression statement, which performs
calculations. Here are some examples of expression statements:
i = a + b;
salesTax = invoiceTotal * taxRate;
System.out.println(“Hello, World!”);

why main class is public and main is static public

Usually word public means that class is accessible for all. Using public keyword with main mehod containing class means that class cobsisting main method should be accessible for other classes.
Static Keyword means that method is accessible at class level without need to create object first as no object could be created before main method called (main is entry point of any programme) so thats why main method is created at class level not object level.

Monday, November 29, 2010

Welcome Programme in c#

using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace SimpleCSharpApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to c#............................!!!!");
}
}
}

Learn Csharp

Csharp is a morcosoft language to compete java thats why both of them are called sister languages. For C# you just first install visual c# 2009. c# is also a fully object oriented language.

Learn Java

To learn Java you must first install and java IDE which you can easily get from internet. I would prefer either net beans or either eclipse. Remember java is fully object oriented language and thus it forces you to write any piece of code in classes. For java first download JDK 6 which is essential for java application. All classes in java are inherited from object class so there is no need of importing that library.

Java welcome programe

public class demo{
public static void main(String[] args)
{
System.out.println("Welcome to JAVA........................!");
}
}