Question: How
do you check whether a table data(values) is sorted or not? Sorting happens
when clicking on Table Header(Ex: Name, which is a link).
Answer:
We can take an array of String type as expected values and consider the column values which need to be verify are as actual values. Which can be resolved by below example.
Name
|
Venu
|
Avinash
|
Dharma
|
We can take an array of String type as expected values and consider the column values which need to be verify are as actual values. Which can be resolved by below example.
import java.util.ArrayList;
import
java.util.Collections;
import java.util.List;
public class CompareTwoLists {
public static void main(String[] ar){
List<String>
expdValues = new
ArrayList<String>();
expdValues.add("venu");
expdValues.add("avinash");
expdValues.add("dharma");
Collections.sort(expdValues); //to arrange given list in sorting
List<String>
actValues = new
ArrayList<String>();
actValues.add("dharma");
actValues.add("venu");
expdValues.add("avinash");
Collections.sort(actValues);
if(expdValues.equals(actValues)){
System.out.println("Given Lists
are Matched");
}else{
System.out.println("Given lists
are not matched");
}
}
}
0 comments:
Post a Comment