Thursday 29 August 2013

HOW TO USE STATIC KEYWORD AS METHOD AND VARIABLE

class student
{
      int rollno;
      String name;
     static String college="GROW MORE";
       student(int r,String n)
       {
        rollno=r;
        name=n;
        }
       static void change()
        {
         college="VN";
        }
       void display()
        {
       
           System.out.println(rollno+" "+name+" "+college);
         }
     public static void main(String Dx[])
     {    
            change();
           

             student s1=new student(111,"KARMA");
             student s2=new student(222,"NIRAV");
           
         
             s1.display();
             s2.display();    
    }

}

STATIC BLOCK PRINT INT JAVA

class static_check
{
      static
      {
                   System.out.println("Static block invoked");  
        } 
 

     public static void main(String Dx[])
     {
          
            System.out.println("Hello, Main method is invoked");

     }

}

HOW TO PRINT A TO Z CHAR BY FOR LOOP

class atoz
{
    public static void main(String Dx[])
     {
            char ch;
         for(ch='A';ch<='Z';ch++)
        {
            System.out.println("  "+ch);
         }
     }

}

Thursday 8 August 2013

hello print in java

class tmp
{

public static void main(String dx[])
  {
    System.out.println("Hello");  
   }
}

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...