Tuesday, 10 September 2013

What is Static Keyword?

In Java,Static Keyword is associated with the class not with the instance of class.Therefore you can access static member without creating a class instance.
There are two types of static members in C++ and Java:
1.Static field:
The value of static field remains same for all the instance of the class.You can interchange the position of static keyword as per your need.Between the function calls its value remains same.
1.1Like: public static int a ;
1.2 static public int a;
Both the statement is same 1.1 and 1.2
If a class has static field StudentId all the objects within the class will have same value for StudentId in the program.It will help in counting the number of objects.
Static field will be accessed by classname.
classname.<static variablename>.
  
Static fields are created and initialized when the class is first loaded.

2.Static Method():
A method declares as static becomes static method which can access only static variables.
Static method is associated with the class not with the instance or object of the class.
Static method we see in our program that is main()which is called by the java runtime to execute an application.
In order to call static method:
classname.staticmethodname();///Sytax for call static method.

Simple Program in Showing USe of Static:
class A
{
int a =10;
static int b=10;
void display()
{a=a+a;
b=b+b;
System.out.println("a");
System.out.println("b");
}
}
public class C
{
public static void main(String args[])
{
A d=new A();
d.display();
A e=new A();

e.display();
}

OUTPUT:
20
20
20
40

System.out.Println Java


We usually use many or dozen of times but do we really know what it is.
System.out.println() just prints the argument passed  into the System.out.

System.out.println():
1.System: It is a final class and cannot be inherited .For further know-how refer to javadocs.
2.out: It is of type PrintStream and static menber of System Class.The Access specifiers for it is public final.
3.println():As braces itself says that it is a function that print whatever pass to it in the standard console.
 Every println makes a call to print method and print calls to write method .

A simple program to print Hello using System.out.println():
class a
{
public static void main(Strings args[])
{
System.out.println("Hello") ;
}
}
Compile:javac a.java
run:java a

Friday, 17 May 2013

Java Projects Java Assignment

Java is not a language it is technology when we talk about java we should know what we can do through Java,how prowerful and secure it is and what constraints and checkpoints we can add to our Webapp,Software or mobile apps in an effective manner.
Java is having three main Edition:
1.Java 2 Standard Edition: (J2SE)
What we can make and Learn in this through this we can make an standalone program like an inventory system or tracking system for a shop,offfice or any manufacturing industry.Simple Standalone application that we can make by using Swing,JDBC and Sqlite as required for our initial Project.
2.Java 2 Enterprise Edition:(J2EE)
When we talk about Enterprise Edition we are mostly talking ERP for a Company,Any Web Based management project by using mutli layer and in depth architecture for development.Here generally we talk about HTML,CSS,Javascript For GUI,JSP,Servlet,Struts,Spring,Design Patterns,Php In java,Ruby in Java and mobile based customization so to have more value to our project.
Simply it is an online Meeting System,Online Banking Management Project etc as this project requires to think in more depth manner by keeping in mind security as first Priority.
Here We can Use Various CMS like Sharepoint,Hippo,OpenCMS,Liferay etc.
3.Java 2 Micro Edition:(J2ME):JAVAME
We are talking about here our mobile portion and there connection with server in order to develop our mobile games,mobile apps  for fun and learning,for security purposes.
It include  each and every section of mobile part and developing it more securily by using Java Technology in an meaningful manner.For Set-top boxes,blu-ray Disc Players etc.
Here we generally use:Java ,SQlite,XML,python etc.


FOR Project or Assignment Help You can contact to our Java Experts at LearnProgramm@gmail.com.
https://www.google.co.in 
https://www.yahoo.com
https://www.twitter.com
https://www.Facebook.com
https://www.w3schools.com
https://www.youtube.com



Monday, 22 August 2011

prime in java


to calculate whether the number is prime or not.prime in java
javalearing.blogspot.com
class prime
{
public static void main(String args[])
{


int num=11;
int i;
for( i=2;i<num;i++)
{
int n=num%i;
if(n==0)
{
System.out.println("not prime");
break;
}
}
if(i==num){
System.out.println("prime number");
}
 }   }

package implementation in java

javalearing.blogspot.com
Here we will show u a simple program of packages and its implementation.
first create a package naming pack(any name)then create class and its method should be static and public  as shown  below:


package pack;
public class hemant
{
public static void show(String s)
{
    System.out.println(s);
    }
    }
save above as hemant.java
now compile your file as: javac hemant.java
now make another file in which you wanted to import your package for example demo.java

import pack.hemant; //for importing package pack having class name hemant
class demo
{
public static void main(String args[])
{
hemant.show("hi bye");
}
}
save above as demo.java
compile your package class first:        javac hemant.java
compile your another file create by you: javac demo.java
run your demo file:java demo
output:
hi bye
finally you get the clear concept of packages.

A JAVA PROGRAM SHOWING OBJECTS AND ITS CLASS IMPLEMENTATION


HERE WE HAVE BOX AS A CLASS WITH WIDTH,HEIGHT AND DEPTH AS ATTRIBUTES AND VOLUME AS METHOD.PROGRAM IS SELF EXPLAINATORY.
class box
{
double width;
double height;
double depth;

public void volume()
{
System.out.println("volume is ");
System.out.println(width*height*depth);
}
}
class boxdemo
{
public static void main(String args[]){
box mybox1=new box();
box mybox2=new box();
mybox1.width=100;
mybox1.height=20;
mybox1.depth=10;
mybox2.width=3;
mybox2.height=6;
mybox2.depth=7;
mybox1.volume();
mybox2.volume();
}
}

NOTEPAD OPENING USING JAVA


QUESTION:NOTEPAD OPENING USING JAVA:
Here we use ProcessBuilder class and create its object following is a simple program opening notepad using java.
import java.io.*;
import java.util.*;
class notepad
{
public static void main(String args[])
{

try
{
ProcessBuilder proc=new ProcessBuilder("notepad.exe","report");
proc.start();
}
catch (Exception e)
{
System.out.println("notepad not open");
}


}
}