Skip to main content

Posts

Showing posts from November, 2017

Java Rules of exception

Rules for exception Rule 1 : If the super class method does not declare an exception, then the overriding method in the subclass cannot declare a checked exception, but can declare an unchecked exception. Rule 2 : If the super class method declares an exception, then the overriding method in the subclass can declare same exception or a subclass exception or no exception at all, but cannot declare parent exception
Setting java environment variobles:- steps 1. go to environment variables. create new system variable NAME : JAVA_HOME PATH : C:\Program Files\Java\jdk1.8.0_151 NAME : path Path : %JAVA_HOME%/bin we need to add both variables in set only either in system variables or in user variables. go to classpath variable add a "."(dot) in classpath.

Looping on 3 D array

Here is the sample program to loop on 3 d Array package test; public class ThreeDArray { public static void main(String[] args) { int[][][] myArrays=   new int[3][3][3]; for( int i=0; i<3; i++){ for(int j=0; j<3;j++){ for (int k = 0; k < 3; k++) { myArrays[i][j][k]=Integer.parseInt(String.valueOf(i)+String.valueOf(j)+String.valueOf(k)); System.out.println(myArrays[i][j][k]); System.out.println(+i+""+j+""+k); } } } } } Example 2 package test; public class ThreeDArray { /** * @param args */ public static void main(String[] args) { int[][][] myArrays=          {             {             {11, 12, 13},             {14, 15, 16},             {17, 18, 19}             },         ...

Iterating over a 2 D array

To iterate over a 2 d array you need to iterate over rows and take one row at a time inside loop and iterate over each column of it . Here is sample program of iterating over a 2 D array package test; public class TwoDArray { public static void main(String[] args) { int i=01; System.out.println(i); int[][] chessBoard=new int[8][8]; //First we will insert Values  in 2 d array for(int row=0; row<chessBoard.length;row++){ for(int column=0; column<chessBoard[row].length; column++){ String combine=String.valueOf(row)+String.valueOf(column); //System.out.println(combine); chessBoard[row][column]=Integer.parseInt(combine); } } //Here we are getting values from a 2D array. for(int row=0; row<chessBoard.length; row++){ for(int col=0; col<chessBoard[row].length;col++){ System.out.println(chessBoard[row][col]); } } } }

Looping Over an array in Automation Script

To loop over an array you can use while loop Example : from psdi.mbo import GLFormat print "****************************testing*****************************" locSet=mbo.getMboSet("LOCATION") glvalue=locSet.getMbo(0).getMboValue("GLACCOUNT").toString() fmt =GLFormat(glvalue,mbo.getString("ORGID")) print fmt.getSegmentCount() glarray=fmt.getSegments() i=0 while(i<len(glarray)) :    print "******************"    print glarray[i]    i=i+1