Thursday 24 November 2022

Charactor_At_Position

public class Char_At_Position {



public static void main(String[] args) {
String str = "Wankhede";
String rev="";
//String rev1="";

System.out.println("String length="+str.length());
System.out.println("character at third position = "+str.charAt(2));
for(int i =str.length()-1;i>=0;i--)
{
char strrev = str.charAt(i);
rev = rev + strrev;
}
System.out.println("Reverse String = "+rev);
StringBuffer sb=new StringBuffer(rev);
sb.reverse();
rev=sb.toString();

System.out.println("Original String = "+rev);
}

}

--
With Warm REGARDS,

En. S. WANKHEDE

Find Duplicate Word in Two Strings

public static void main(String[] args) {
String str1 = "awankhede";
String str2 = "aaadeea";
char c = 0;
int i,w = 0;
int len1 = str1.length();
int len2 = str2.length();
for(i=0;i<=len1-1;i++)
{
for(int j=0;j<=len2-1;j++)
{
if(str1.charAt(i)==str2.charAt(j))
w++;
if(str1.charAt(i)==str2.charAt(j))
c=str1.charAt(i);

}

}

System.out.println("Duplicate character   " +c+"   number of times  "+(w+1));
}

--
With Warm REGARDS,

En. S. WANKHEDE

Number Reverse

public static void main(String[] args) {
int n=121;
int rev=0;
while(n!=0)
{
rev = rev*10+n%10;
n=n/10;
}
System.out.println(rev);
if(n==rev)
System.out.println("number is palindrome");
else
System.out.println("number is not palindrome");
}

--
With Warm REGARDS,

En. S. WANKHEDE

Number of Even and odd in given numbers


public static void main(String[] args) {
int n=12345;
int odd=0;
int even=0;
while(n!=0)
{
int r=n%10;
if(r%2==0)
{
even++;
}
else
{
odd++;
}
n=n/10;
}
System.out.println(even);
System.out.println(odd);
int n1=1000;
int c=0;
while(n1!=0)
{
n1=n1/10;
c++;
}
System.out.println(c);
}
--
With Warm REGARDS,

En. S. WANKHEDE

Removing White Spaces between string


public static void main(String[] args)
{
String str = "wan   khede";
StringBuffer sb = new StringBuffer();
char [] ch = str.toCharArray();
for(int i=0;i<=str.length()-1;i++)
{

if(ch[i]!=' ')
{
sb=sb.append(str.charAt(i));
}

}
String str1 = sb.toString();
System.out.println(str1);

}


 
--
With Warm REGARDS,

En. S. WANKHEDE

String Compare

 public static void main(String[] args) {
String str1="Wankhede";
String str2 = "Wankhede";
if(str1==str2)
{
System.out.println("String Equals");
}
else
{
System.out.println("String not Equals");
}


}




--
With Warm REGARDS,

En. S. WANKHEDE

String Swap Count_White Space Reverse String

public static void main(String[] args) {
String str1="Shivaji";
String str2 = "Wankhede";
String str3="wa    kh  ede";
int c=0;
System.out.println("string1="+str1);
System.out.println("string2="+str2);
str1=str1+str2;
str2= str1.substring(0,str1.length() - str2.length());
System.out.println("string2 "+str2);
str1=str1.substring(str2.length());
System.out.println("String1 "+str1);

// counting length of white spaces
for(int i=0;i<=str3.length()-1;i++)
{
if(str3.charAt(i)==' ')
{
c++;
}
}
System.out.println("Blank Spaces: " + c);

//Reverse string
String rev=" ";
for(int i=str2.length()-1;i>=0; i--)
{
rev = rev+str2.charAt(i);
}
System.out.println("reverse string : " + rev);

}

--
With Warm REGARDS,

En. S. WANKHEDE

Fwd: String Reverse and Palindrom



---------- Forwarded message ---------
From: En. S. Wankhede <shivaji.wankhede@gmail.com>
Date: Thu, Oct 20, 2022 at 8:38 PM
Subject: String Reverse and Palindrom
To: <shivaji.wankhede.java@blogger.com>



public static void main(String[] args) {
String str="Shivaji";
//String str1="Wankhede";
String str3 ="Wa  ";
String rev="";
int c = 0;
// char rev = 0;
int l=str.length();
for(int i=l-1;i>=0;i--)
{
rev = rev + str.charAt(i);
}
System.out.println("reverse string = "+rev);

if(str.equals(rev))
{
System.out.println("String is palandrom");
}
else
{
System.out.println("String is not palandrom");
}

for(int i=0;i<str3.length()-1;i++)
{
char ch = str3.charAt(i);
if(ch==' ')
{
c++;
}

}

System.out.println("number of white spaces="+c);


for(int i=0;i<str3.length()-1;i++)
{
char ch = str3.charAt(i);
if(ch==' ' && ch!=' '&&ch!='\t')
{
c++;
}

}
System.out.println("number of words="+c);
}




--
With Warm REGARDS,

En. S. WANKHEDE


--
With Warm REGARDS,

En. S. WANKHEDE

TestNG Code Samples POM.xml file Maven Project

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>TestNGFramework</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>TestNGFramework</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
</properties>

<dependencies>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.5.3</version>
</dependency>


<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.3.1</version>

</dependency>


<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.6.0</version>

</dependency>



<!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>5.0.8</version>
</dependency>

</dependencies>
</project>

--
With Warm REGARDS,

En. S. WANKHEDE

TestNG Project testng.xml file selenium Testing


<?xml version="1.0" encoding="UTF-8"?>
<suite name="suite 1" verbose="1" >
<test name="Regression suite 1" >

<listners>
<listner name="Listners.Listners"></listner>
</listners>


<classes>
<class name="ExtentReports.Load_Test"/>
<class name="ExtentReports.Window_Maximize"/>
<class name="ExtentReports.Check_Title"/>
<class name="ExtentReports.Check_User_Name"/>
<class name="ExtentReports.Check_Password_Box"/>
<class name="ExtentReports.Check_Logging_In"/>
<class name="ExtentReports.Check_Page_Info"/>
<class name="ExtentReports.Check_Drop_Down"/>
<class name="ExtentReports.Count_Cards"/>
<class name="ExtentReports.Add_To_Cart"/>
<class name="ExtentReports.Check_Menu_Button"/>
<class name="ExtentReports.Take_Screenschot"/>
</classes>

</test>
</suite>
--
With Warm REGARDS,

En. S. WANKHEDE

Charactor_At_Position

public class Char_At_Position { public static void main(String[] args) { String str = "Wankhede"; String rev=""...