Dynamic Table

import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; public class Dynamictable { WebDriver driver = new FirefoxDriver(); @BeforeTest public void setup() throws Exception { driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); driver.get(“http://only-testing-blog.blogspot.in/2014/05/form.html”); } @AfterTest public void tearDown() throws Exception { driver.quit(); } @Test public void Handle_Dynamic_Webtable() { //To locate…

Java Uses- Builder Pattern

Builder pattern is used to create a complex object using simple objects. It creates the bigger object step by step from small and simple object. Builder pattern is another creational pattern. For example, when creating a window as our application’s main window, we need to create a menu, a toolbar and then add the menu…

Scala uses

In Scala, you can define variables val and lazy val. Scala allows you to decide, when you can declare variable immutable whether or not.          Val This is immutable variable declared with the key word val. It means, we cannot change variable. The following code can creates a value with the name…

Singleton Object

Method- public class SingleObject { //create an object of SingleObject private static SingleObject instance = new SingleObject(); //make the constructor private so that this class cannot be //instantiated private SingleObject(){} //Get the only object available public static SingleObject getInstance(){ return instance; } public void showMessage(){ System.out.println(“Hello World!”); } } Call method- public class SingletonPatternDemo {…

Sum and Average of Array Example

package com.java.training;

public class SumandAvgofthearray {
public static void main (String[]args){
int a[]={2,8,6,4,3,9};
System.out.println(“Size of array=” +a.length);

float sum=0.0f;
float avg=0.0f;
for(int i=0;i<a.length;i++){
sum=sum+a[i];
avg=sum/(a.length*1.0f);

}
System.out.println(“Sum Of the array=”+sum);
System.out.println(“Avg Of the array=”+avg);
}
}

 

Output-

Size of array=6
Sum Of the array=32.0
Avg Of the array=5.3333335