Skip to main content

Posts

Showing posts from February, 2014

calculator

package com.play; import java.io.Console; import java.util.Scanner; public class Calculator { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Enter a Numebr"); Scanner f= new  Scanner(System.in); int firstNum=f.nextInt(); System.out.println("Enter another Numebr"); Scanner s= new  Scanner(System.in); int SecondNum=s.nextInt(); System.out.println("Choose the following option 1: Add 2: substract 3: divide 4: multiply"); Scanner option= new  Scanner(System.in); int Choosedoption=option.nextInt(); switch (Choosedoption) { case 1: System.out.println(Add(firstNum,SecondNum)); case 2: System.out.println(Substract(firstNum,SecondNum)); case 3: System.out.println(Divide(firstNum,SecondNum)); case 4: System.out.println(Multiply(firstNum,SecondNum)); } } public static int Add(int firstnum, int secNum...

basic java

string text = "500"; int num = int.Parse (text); Console.WriteLine(num);       String text = "500"; int num = int.Parse (text); System.out.println(num); ----------------------------------------------------------- String text = "500";   int num = int.Parse (text);//incorrect int num = Integer.parseInt(text);//do this System.out.println(num);

Java inheritance question ?

package com.vit; public class InheritanceDemo {     public static void main(String args[])     {           Super1 super1 = new Super2();         super1.base1();                 Super2 super2 = new Super3();         super2.base1();             } } class Super1 {      public Super1()      {          System.out.println("with in super1()");      }      public void base1()      {          System.out.println("Base is called from super1");      } } class Super2 extends Super1 {      public Super2()      { ...

Shortcuts in eclipse

Shortcuts in eclipse control + shift + O = For importing all the class library control + f11= To run the java project f11= To run in debug perspective control + ? = to comment on the code control + space= For importing the class library and to find out the multiple option for class or methods   alt + shift + R= refactor: rename  alt+ shift + T= refactor : have an option for multiple choice.