<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Selenium Webdriver Appium Complete Tutorial</title>
	<atom:link href="https://automationtesting.in/feed/" rel="self" type="application/rss+xml" />
	<link>https://automationtesting.in/</link>
	<description>Automation Testing</description>
	<lastBuildDate>Wed, 20 Jul 2022 01:44:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.2</generator>
	<item>
		<title>How to Capture WebElement Screenshot in Selenium Webdriver using selenium 4</title>
		<link>https://automationtesting.in/how-to-capture-webelement-screenshot-in-selenium-webdriver/</link>
					<comments>https://automationtesting.in/how-to-capture-webelement-screenshot-in-selenium-webdriver/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Sun, 15 Dec 2019 17:47:24 +0000</pubDate>
				<category><![CDATA[Selenium - Java]]></category>
		<category><![CDATA[capture full page screenshot in selenium 4]]></category>
		<category><![CDATA[capture screenshot in selenium]]></category>
		<category><![CDATA[capture screenshot using webelement]]></category>
		<category><![CDATA[capturescreenshot]]></category>
		<category><![CDATA[capturescreenshot using selenium]]></category>
		<category><![CDATA[how to capture screenshot in selenium]]></category>
		<category><![CDATA[how to capture screenshot in selenium webdriver]]></category>
		<category><![CDATA[how to capture webelement screenshot in selenium webdriver]]></category>
		<category><![CDATA[how to take screenshot in selenium]]></category>
		<category><![CDATA[how to take screenshot in selenium webdriver]]></category>
		<category><![CDATA[new features in selenium 4]]></category>
		<category><![CDATA[screenshot in selenium]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[selenium 4]]></category>
		<category><![CDATA[Selenium Webdriver]]></category>
		<category><![CDATA[take screenshot of webelement in selenium]]></category>
		<category><![CDATA[takescreenshot in selenium]]></category>
		<guid isPermaLink="false">http://automationtesting.in/?p=2356</guid>

					<description><![CDATA[<p>In this blog, we will learn how to capture webelement screenshot using selenium. Till Selenium 3 we have an option that to take the screenshot for an entire webpage. From selenium 4 onwards they have introduced an option that to capture a webelement. Previously, using some third party libraries like Ashot, shutterbug to capture the [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://automationtesting.in/how-to-capture-webelement-screenshot-in-selenium-webdriver/">How to Capture WebElement Screenshot in Selenium Webdriver using selenium 4</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script><br />
(adsbygoogle = window.adsbygoogle || []).push({});<br />
</script></p>
<p>In this blog, we will learn how to capture webelement screenshot using selenium. Till Selenium 3 we have an option that to take the screenshot for an entire webpage. From selenium 4 onwards they have introduced an option that to capture a webelement. Previously, using some third party libraries like Ashot, shutterbug to capture the webelemet or webpage.</p>
<div class="post-video"><iframe loading="lazy" title="How to Capture WebElement Screenshot in Selenium Webdriver || Interview Question || Method 1" width="1165" height="874" src="https://www.youtube.com/embed/Jz2_MlVO5c8?wmode=transparent&#038;fs=1"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p><script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script><br />
(adsbygoogle = window.adsbygoogle || []).push({});<br />
</script></p>
<p><strong>Pre-requisites</strong>:</p>
<ol>
<li>Add the selenium-4-alpha.jar file in your project or add the corresponding dependency is yours is a Maven project</li>
<li>in your class file, inspect the target element and store it in a webelement.</li>
<li>Now, use the regular screenshot logic method and store the value in a folder using Filehandler method.</li>
<li>Instead of driver, use the webelement reference variable to capture the screenshot of the target element instead of full webpage.</li>
</ol>
<pre class="brush: java; title: ; notranslate">
package Basics;

import java.io.File;

import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.io.FileHandler;

public class CaptureWebelementScreenshot {

public static void main(String&#x5B;] args) throws Exception {
// TODO Auto-generated method stub
WebDriver driver;
System.setProperty(&quot;webdriver.chrome.driver&quot;, &quot;E:\\Selenium-Softwares\\chromedriver.exe&quot;);
//System.setProperty(&quot;webdriver.gecko.driver&quot;, &quot;E:\\Selenium-Softwares\\geckodriver.exe&quot;);
driver=new ChromeDriver();
driver.get(&quot;http://demo.automationtesting.in/Register.html&quot;);
Thread.sleep(3000);
WebElement element = driver.findElement(By.id(&quot;imagetrgt&quot;));

File source = ((TakesScreenshot)element).getScreenshotAs(OutputType.FILE);
FileHandler.copy(source, new File(&quot;./screenshots/element.png&quot;));
Thread.sleep(3000);
driver.quit();

}

}

</pre>
<p><a href="https://www.youtube.com/watch?v=Jz2_MlVO5c8">Please watch the Youtube video for better understanding.</a><br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script><br />
(adsbygoogle = window.adsbygoogle || []).push({});<br />
</script></p>
<div id="themify_builder_content-2356" data-postid="2356" class="themify_builder_content themify_builder_content-2356 themify_builder themify_builder_front">

	</div>
<!-- /themify_builder_content --><p>The post <a rel="nofollow" href="https://automationtesting.in/how-to-capture-webelement-screenshot-in-selenium-webdriver/">How to Capture WebElement Screenshot in Selenium Webdriver using selenium 4</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://automationtesting.in/how-to-capture-webelement-screenshot-in-selenium-webdriver/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to SWAP Two Numbers in Java Without Temp variable or Without Third variable</title>
		<link>https://automationtesting.in/swap-two-numbers-java-without-temp-variable-without-third-variable/</link>
					<comments>https://automationtesting.in/swap-two-numbers-java-without-temp-variable-without-third-variable/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Sun, 08 Dec 2019 07:02:53 +0000</pubDate>
				<category><![CDATA[Java IQs]]></category>
		<category><![CDATA[swap operation without using temp in java]]></category>
		<category><![CDATA[swap two numbers without using third variable]]></category>
		<category><![CDATA[swap two variables]]></category>
		<category><![CDATA[swap two variables in java]]></category>
		<category><![CDATA[swap two variables in java without using temp variable]]></category>
		<guid isPermaLink="false">http://automationtesting.in/?p=2343</guid>

					<description><![CDATA[<p>In this blog, we will see How to SWAP Two Numbers in Java without Temp Variable or without third variable. This will be asked in the most of the interview questions. In the below snippet, we have done the following to swap two numbers without using temp variable: Create two int variables and assign them [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://automationtesting.in/swap-two-numbers-java-without-temp-variable-without-third-variable/">How to SWAP Two Numbers in Java Without Temp variable or Without Third variable</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
In this blog, we will see How to SWAP Two Numbers in Java without Temp Variable or without third variable. This will be asked in the most of the interview questions.</p>
<div class="post-video"><iframe loading="lazy" title="8. How to SWAP Two Numbers in Java Without Temp or Without Third Variable | Java Interview Questions" width="1165" height="874" src="https://www.youtube.com/embed/wnfvVpG1J7c?wmode=transparent&#038;fs=1"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --></p>
<p>In the below snippet, we have done the following to swap two numbers without using temp variable:</p>
<ol>
<li>Create two int variables and assign them with some values. Here we have taken a=20 and b=30 respectively.</li>
<li>Here, swap operation can be done by assigning the values of variables (a and b) to one another as below and getting the latest values in those respective variables which is shown in the below code:</li>
</ol>
<p><ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<pre class="brush: java; title: ; notranslate">
package Javaprograms;

public class SwapTwoNumbersWithoutTempVariable {

	public static void main(String&#x5B;] args) {
		int a = 20;
		int b = 30;
		
		System.out.println(&quot;a value before swapping is:&quot; +a);
		System.out.println(&quot;b value before swapping is:&quot; +b);
		
		System.out.println(&quot;---------------------------------&quot;);
		a = a+b; // a=20 + b=30; now a value = 50
		b = a-b; // a=50 - b=30; now b value = 20
		a = a-b; // a=50 - b=20; now a value = 30
		
		System.out.println(&quot;a value after swapping is:&quot; +a);
		System.out.println(&quot;b value after swapping is:&quot; +b);
		
	}

}
</pre>
<pre class="brush: java; title: ; notranslate">
Output:
--------
a value before swapping is:20
b value before swapping is:30
---------------------------------
a value after swapping is:30
b value after swapping is:20

</pre>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<a href="https://www.youtube.com/watch?v=wnfvVpG1J7c">Please watch the Youtube video for better understanding.</a><br />
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<div id="themify_builder_content-2343" data-postid="2343" class="themify_builder_content themify_builder_content-2343 themify_builder themify_builder_front">

	</div>
<!-- /themify_builder_content --><p>The post <a rel="nofollow" href="https://automationtesting.in/swap-two-numbers-java-without-temp-variable-without-third-variable/">How to SWAP Two Numbers in Java Without Temp variable or Without Third variable</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://automationtesting.in/swap-two-numbers-java-without-temp-variable-without-third-variable/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to SWAP Two Numbers in Java using Temp Variable</title>
		<link>https://automationtesting.in/how-to-swap-two-numbers-in-java-using-temp-variable/</link>
					<comments>https://automationtesting.in/how-to-swap-two-numbers-in-java-using-temp-variable/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Sun, 01 Dec 2019 04:12:32 +0000</pubDate>
				<category><![CDATA[Java IQs]]></category>
		<category><![CDATA[swap operation using temp in java]]></category>
		<category><![CDATA[swap two variables]]></category>
		<category><![CDATA[swap two variables in java]]></category>
		<category><![CDATA[swap two variables in java using temp variable]]></category>
		<guid isPermaLink="false">http://automationtesting.in/?p=2331</guid>

					<description><![CDATA[<p>In this blog, we will see How to SWAP Two Numbers in Java using Temp Variable. This will be asked in the most of the interview questions. In the below snippet, we have done the following to swap two numbers using temp variable: Create two int variables and assign them with some values. Here we [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://automationtesting.in/how-to-swap-two-numbers-in-java-using-temp-variable/">How to SWAP Two Numbers in Java using Temp Variable</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
In this blog, we will see How to SWAP Two Numbers in Java using Temp Variable. This will be asked in the most of the interview questions.</p>
<div class="post-video"><iframe loading="lazy" title="7. How to SWAP Two Numbers in Java Using Temp Variable|Using Third Variable|Java Interview Questions" width="1165" height="874" src="https://www.youtube.com/embed/DttionNoAFs?wmode=transparent&#038;fs=1"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive -->In the below snippet, we have done the following to swap two numbers using temp variable:</p>
<ol>
<li>Create two int variables and assign them with some values. Here we have taken a=20 and b=30 respectively.</li>
<li>Now take another variable and name it as Temp</li>
<li>Here, swap operation can be done by assigning the values of variables (a and b) using Temp as a Helper which is shown in the below code:</li>
</ol>
<p><ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<pre class="brush: java; title: ; notranslate">
package Javaprograms;

public class SwapTwoNumbersUsingTempVariable {

	public static void main(String&#x5B;] args) {
		int a= 20;
		int b= 30;
		int temp;
		System.out.println(&quot;A vlaue before swapping is &quot; +a);
		System.out.println(&quot;B vlaue before swapping is &quot; +b);
		System.out.println(&quot;---------------------&quot;);
		
		temp = a;
		a = b;
		a = temp;
		
		System.out.println(&quot;A vlaue after swapping is &quot; +a);
		System.out.println(&quot;B vlaue after swapping is &quot; +b);

	}

}

</pre>
<pre class="brush: java; title: ; notranslate">
Output:
------
a value before swapping is:20
b value before swapping is:30
---------------------------------
a value after swapping is:30
b value after swapping is:20

</pre>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<a href="https://www.youtube.com/watch?v=DttionNoAFs">Please watch the Youtube video for better understanding.</a><br />
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<div id="themify_builder_content-2331" data-postid="2331" class="themify_builder_content themify_builder_content-2331 themify_builder themify_builder_front">

	</div>
<!-- /themify_builder_content --><p>The post <a rel="nofollow" href="https://automationtesting.in/how-to-swap-two-numbers-in-java-using-temp-variable/">How to SWAP Two Numbers in Java using Temp Variable</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://automationtesting.in/how-to-swap-two-numbers-in-java-using-temp-variable/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Read Data From Properties File in Java</title>
		<link>https://automationtesting.in/how-to-read-data-from-properties-file-in-java/</link>
					<comments>https://automationtesting.in/how-to-read-data-from-properties-file-in-java/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Wed, 27 Nov 2019 08:13:30 +0000</pubDate>
				<category><![CDATA[Java IQs]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[How to Read Data from properties file]]></category>
		<category><![CDATA[Read Data from Properties file]]></category>
		<category><![CDATA[Read Data from Properties file in java]]></category>
		<guid isPermaLink="false">http://automationtesting.in/?p=2311</guid>

					<description><![CDATA[<p>In this blog, we will see How to Read Data From Properties File in Java. This will be asked in the most of the interview questions. Things to Remember: Mostly, the properties file is used to maintain the configurable parameters of the project. Extension for this file is &#8220;.properties&#8221; Properties file data will be in [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://automationtesting.in/how-to-read-data-from-properties-file-in-java/">How to Read Data From Properties File in Java</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img src='http://automationtesting.in/wp-content/uploads/2019/11/How-to-Read-Properties-file-in-Java.png'></p><p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<p>In this blog, we will see How to Read Data From Properties File in Java. This will be asked in the most of the interview questions.</p>
<p><strong>Things to Remember:</strong></p>
<ol>
<li>Mostly, the properties file is used to maintain the configurable parameters of the project.</li>
<li>Extension for this file is &#8220;.properties&#8221;</li>
<li>Properties file data will be in a Key and Value pair format.</li>
<li>whenever you&#8217;re creating a properties file, maintain the keys in unique format. Don&#8217;t use the existing key for your new value.
<ul>
<li>If you use the existing key again, then whenever control searches for that key it will return the last searched value. This might leads to conflicts.</li>
</ul>
</li>
</ol>
<pre class="brush: java; title: ; notranslate">
#CONFIG File
username = Username
password = pass
firstname = fname
</pre>
<div class="post-video"><iframe loading="lazy" title="6.  How to Read Data From Properties File in Java | Properties File | Java Interview Questions" width="1165" height="874" src="https://www.youtube.com/embed/OBnjTszNe3c?wmode=transparent&#038;fs=1"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
In the below snippet, we have done the following to Read Data from properties file:</p>
<ol>
<li>Created a new folder under our project and created  a new properties file with some data</li>
<li>Created a object and assigned the file location of this newly created properties file using FileInputStream class.</li>
<li>Created a object for the Properties class.</li>
<li>Loaded all the properties of our file using Properties.load() method.</li>
<li>Using .getProperty() method, we can load all our data using Key as a parameter.</li>
<li>Then, it prints the corresponding value of that key.</li>
</ol>
<pre class="brush: java; title: ; notranslate">
package Javaprograms;

import java.io.FileInputStream;
import java.util.Properties;

public class ReadDataFromPropertiesFile {

	public static void main(String&#x5B;] args) throws Exception {
		FileInputStream fis = new FileInputStream(&amp;quot;E:/Selenium/SeleniumPrgrms/resources/config.properties&amp;quot;);
		Properties prop = new Properties();
		
		prop.load(fis);
		
		String user = prop.getProperty(&amp;quot;username&amp;quot;);
		String pword = prop.getProperty(&amp;quot;password&amp;quot;);
		String fname = prop.getProperty(&amp;quot;firstname&amp;quot;);
		
		System.out.println(user);
		System.out.println(pword);
		System.out.println(fname);
	}

}
</pre>
<pre class="brush: java; title: ; notranslate">
Output:
--------
username = Username
password = pass
firstname = fname
</pre>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<a href="https://www.youtube.com/watch?v=OBnjTszNe3c">Please watch the Youtube video for better understanding.</a><br />
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<div id="themify_builder_content-2311" data-postid="2311" class="themify_builder_content themify_builder_content-2311 themify_builder themify_builder_front">

	</div>
<!-- /themify_builder_content --><p>The post <a rel="nofollow" href="https://automationtesting.in/how-to-read-data-from-properties-file-in-java/">How to Read Data From Properties File in Java</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://automationtesting.in/how-to-read-data-from-properties-file-in-java/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Compare Two Arrays in Java without built-in functions</title>
		<link>https://automationtesting.in/compare-two-arrays-java-without-built-functions/</link>
					<comments>https://automationtesting.in/compare-two-arrays-java-without-built-functions/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Sat, 16 Nov 2019 13:05:01 +0000</pubDate>
				<category><![CDATA[Java IQs]]></category>
		<category><![CDATA[comapre arrays]]></category>
		<category><![CDATA[Compare arrays in Java]]></category>
		<category><![CDATA[compare arrays without inbuilt functions]]></category>
		<category><![CDATA[compare two arrays in java]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">http://automationtesting.in/?p=2298</guid>

					<description><![CDATA[<p>In this blog, we will see how to compare two arrays in java without in-built functions. This will be asked in the most of the interview questions. In the below snippet, we have done the following: Created two arrays of same datatype and assigned those with some elements Created a helper class with parameters  of [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://automationtesting.in/compare-two-arrays-java-without-built-functions/">How to Compare Two Arrays in Java without built-in functions</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
In this blog, we will see how to compare two arrays in java without in-built functions. This will be asked in the most of the interview questions.</p>
<div class="post-video"><iframe loading="lazy" title="5. How To Compare Two Arrays in Java | Without InBuilt Functions | Java Interview Questions" width="1165" height="655" src="https://www.youtube.com/embed/QRTweZCmlUc?t=655s&#038;wmode=transparent&#038;fs=1"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p>In the below snippet, we have done the following:</p>
<ol>
<li>Created two arrays of same datatype and assigned those with some elements</li>
<li>Created a helper class with parameters  of these two arrays</li>
<li>Inside the helper class, to compare the arrays we have done the following
<ul>
<li>Firstly, we compared both the declared arrays length are equal or not using arrayname.length() and returned the value</li>
<li>Then, we have iterated a for loop based on array.length() and then compared the arrays index is equal or not and returned the value.</li>
</ul>
</li>
<li>In the main method, we mentioned an If condition which will validate the result based on the returned value.</li>
</ol>
<pre class="brush: java; title: ; notranslate">
package Javaprograms;

public class CompareArraysWithoutInBuiltFunctions {

	public static void main(String&#x5B;] args) {
		String a&#x5B;] = {&quot;apple&quot;,&quot;bat&quot;,&quot;cat&quot;};
		String b&#x5B;] = {&quot;apple&quot;,&quot;bat&quot;,&quot;catt&quot;};
		
		if(arraysCompareCheck(a, b)){
			System.out.println(&quot;Both arrays are equal&quot;);
		}
		else
		{
			System.out.println(&quot;Both arrays are not equal&quot;);
		}
		
	}
		public static boolean arraysCompareCheck(String a&#x5B;], String b&#x5B;]){
			if(a.length!=b.length){
				return false;
			}
			else
			{
				for(int i=0;i&lt;a.length;i++)
				{
					if(a&#x5B;i]!=b&#x5B;i])
					{
						return false;
					}	
				}			
			}
			return true;		
		}
	}
</pre>
<pre class="brush: java; title: ; notranslate">
Output:
--------
Both arrays are not equal
</pre>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
Here, It&#8217;s better to use the Object class as a parameter as it is the super class which can inherit all the datatypes and supports whatever the array&#8217;s datatype is.</p>
<p>Below is the snippet which uses the Object class as a parameter:</p>
<p><b>If you&#8217;re using an integer array with an object class parameter, Make sure to use the derived datatype Integer instead of Int</b></p>
<pre class="brush: java; title: ; notranslate">
package Javaprograms;

public class CompareArraysWithoutInBuiltFunctions {

	public static void main(String&#x5B;] args) {
		//String a&#x5B;] = {&quot;apple&quot;,&quot;bat&quot;,&quot;cat&quot;};
		//String b&#x5B;] = {&quot;apple&quot;,&quot;bat&quot;,&quot;catt&quot;};
		
		Integer a&#x5B;] = {1,2,19};
		Integer b&#x5B;] = {1,2,19};
		
		if(arraysCompareCheck(a, b)){
			System.out.println(&quot;Both arrays are equal&quot;);
		}
		else
		{
			System.out.println(&quot;Both arrays are not equal&quot;);
		}
		
	}
		public static boolean arraysCompareCheck(Object a&#x5B;], Object b&#x5B;]){
			if(a.length!=b.length){
				return false;
			}
			else
			{
				for(int i=0;i&lt;a.length;i++)
				{
					if(a&#x5B;i]!=b&#x5B;i])
					{
						return false;
					}	
				}			
			}
			return true;		
		}
	}
</pre>
<pre class="brush: java; title: ; notranslate">
Output:
-------
Both Arrays are equal
</pre>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<a href="https://www.youtube.com/watch?v=QRTweZCmlUc&amp;t=655s">Please watch the Youtube video for better understanding.</a><br />
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<div id="themify_builder_content-2298" data-postid="2298" class="themify_builder_content themify_builder_content-2298 themify_builder themify_builder_front">

	</div>
<!-- /themify_builder_content --><p>The post <a rel="nofollow" href="https://automationtesting.in/compare-two-arrays-java-without-built-functions/">How to Compare Two Arrays in Java without built-in functions</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://automationtesting.in/compare-two-arrays-java-without-built-functions/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Compare Two Arrays in Java using built-in functions</title>
		<link>https://automationtesting.in/how-to-compare-two-arrays-in-java-using-built-in-functions/</link>
					<comments>https://automationtesting.in/how-to-compare-two-arrays-in-java-using-built-in-functions/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Sat, 16 Nov 2019 10:58:05 +0000</pubDate>
				<category><![CDATA[Java IQs]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[compare arrays]]></category>
		<category><![CDATA[compare two arrays in java]]></category>
		<category><![CDATA[compare two arrays in java using built-in functions]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">http://automationtesting.in/?p=2219</guid>

					<description><![CDATA[<p>In this blog, we will learn how to compare two arrays in Java using built-in functions. This will be asked in the most of the interviews. This can be implemented in the below way: In the below snippet, we have done the following: Created two arrays and assigned some elements in it. Using built-in function [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://automationtesting.in/how-to-compare-two-arrays-in-java-using-built-in-functions/">How to Compare Two Arrays in Java using built-in functions</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<p>In this blog, we will learn how to compare two arrays in Java using built-in functions. This will be asked in the most of the interviews. This can be implemented in the below way:</p>
<div class="post-video"><iframe loading="lazy" title="4. How To Compare Two Arrays in Java | Arrays.equals() Method | Java Interview Questions" width="1165" height="655" src="https://www.youtube.com/embed/dGDlX09rI5k?wmode=transparent&#038;fs=1"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p>In the below snippet, we have done the following:</p>
<ol>
<li>Created two arrays and assigned some elements in it.</li>
<li>Using built-in function Arrays.equals method we can compare our two arrays and validate them accordingly.</li>
<li>Here, we have declared the two arrays differently, one with 3 elements and the other array with 4 elements</li>
<li>Validating them using If statement and the built-in function as mentioned above</li>
</ol>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<pre class="brush: java; title: ; notranslate">

package Javaprograms;

import java.util.Arrays;

public class CompareArrays {

	public static void main(String&#x5B;] args) {
		int a&#x5B;] = {1,3,5};
		int b&#x5B;] = {1,3,4,5};
		
		if(Arrays.equals(a, b))
		{
			System.out.println(&quot;Both the Arrays are EQUAL&quot;);
		}
		else
		{
			System.out.println(&quot;Both the Arrays are not EQUAL&quot;);
		}
	}

}
</pre>
<pre class="brush: java; title: ; notranslate">
Output:
-------
Both the Arrays are not EQUAL
</pre>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
In the below snippet, we have done the following:</p>
<ol>
<li>using the same above arrays, But in this instance we have used the equal elements and equal values in their indices of those arrays to see the result as Equal.</li>
</ol>
<pre class="brush: java; title: ; notranslate">
package Javaprograms;

import java.util.Arrays;

public class CompareArrays {

	public static void main(String&#x5B;] args) {
		int a&#x5B;] = {1,3,5};
		int b&#x5B;] = {1,3,5};
		
		if(Arrays.equals(a, b))
		{
			System.out.println(&quot;Both the Arrays are EQUAL&quot;);
		}
		else
		{
			System.out.println(&quot;Both the Arrays are not EQUAL&quot;);
		}
	}

}

</pre>
<pre class="brush: java; title: ; notranslate">
Output:
-------
Both the Arrays are EQUAL
</pre>
<p><a href="https://www.youtube.com/watch?v=dGDlX09rI5k">Please watch the Youtube video for better understanding.</a><br />
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<div id="themify_builder_content-2219" data-postid="2219" class="themify_builder_content themify_builder_content-2219 themify_builder themify_builder_front">

	</div>
<!-- /themify_builder_content --><p>The post <a rel="nofollow" href="https://automationtesting.in/how-to-compare-two-arrays-in-java-using-built-in-functions/">How to Compare Two Arrays in Java using built-in functions</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://automationtesting.in/how-to-compare-two-arrays-in-java-using-built-in-functions/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Remove Whitespaces from a String in Java</title>
		<link>https://automationtesting.in/how-to-remove-whitespaces-from-a-string-in-java/</link>
					<comments>https://automationtesting.in/how-to-remove-whitespaces-from-a-string-in-java/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Mon, 11 Nov 2019 11:39:48 +0000</pubDate>
				<category><![CDATA[Java IQs]]></category>
		<category><![CDATA[remove whitespace in a string]]></category>
		<category><![CDATA[remove whitespaces]]></category>
		<category><![CDATA[remove whitespaces from a string]]></category>
		<category><![CDATA[remove whitespaces from a string using java]]></category>
		<category><![CDATA[replaceAll method in string]]></category>
		<guid isPermaLink="false">http://automationtesting.in/?p=2181</guid>

					<description><![CDATA[<p>In this blog, we will learn how to remove whitespaces from a string in Java. This will be asked in the most of the interviews. This can be implemented in three different ways listed below: Convert String into character array and use for loop For loop with charAt() method Using replaceAll() method Method 1: Convert [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://automationtesting.in/how-to-remove-whitespaces-from-a-string-in-java/">How to Remove Whitespaces from a String in Java</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<p>In this blog, we will learn how to remove whitespaces from a string in Java. This will be asked in the most of the interviews. This can be implemented in three different ways listed below:</p>
<ol>
<li>Convert String into character array and use for loop</li>
<li>For loop with charAt() method</li>
<li>Using replaceAll() method</li>
</ol>
<div class="post-video"><iframe loading="lazy" title="2. Remove Whitespaces from a String in Java - Java Interview Questions ( 3 ways)" width="1165" height="655" src="https://www.youtube.com/embed/ZsmayCezAwo?wmode=transparent&#038;fs=1"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<h3><strong><span style="color: #0000ff;">Method 1:</span></strong></h3>
<p><strong>Convert String into Character array and use for loop</strong></p>
<p>In the below snippet we have done the following</p>
<ul>
<li>Created a string and assigned it with some value (includes whitespaces)</li>
<li>Created a character array and converted the string into the array by using .toCharArray() method</li>
<li>Created another empty string to store the output string</li>
<li>By using char.length() method we&#8217;ve iterated for loop</li>
<li>Used a If statement with a condition that to store only the values which are of not a period(whitespace) type.</li>
</ul>
<pre class="brush: java; title: ; notranslate">
public class RemoveWhitespacesString {

	public static void main(String&#x5B;] args) {
		
		String str = &quot;Java is a programming language&quot;;
		char ch &#x5B;] = str.toCharArray();
		String str2 = &quot;&quot;;
		for(int i=0; i&lt;ch.length; i++)
		{
			if(ch&#x5B;i]!=' ')
			{
				str2 = str2 + ch&#x5B;i];
			}
		}
		
		System.out.println(str2);
	}
}
</pre>
<pre class="brush: java; title: ; notranslate">
Output:
-------
Javaisaprogramminglanguage
</pre>
<h3><strong><span style="color: #0000ff;">Method 2:</span></strong></h3>
<p><strong>Convert String into Character array and use for loop with CharAt() method</strong></p>
<p>In the below snippet we have done the following</p>
<ul>
<li>Created a string and assigned it with some value (includes whitespaces)</li>
<li>Created a character array and converted the string into the array by using .toCharArray() method</li>
<li>Created another empty string to store the output string</li>
<li>By using char.length() method we&#8217;ve iterated for loop</li>
<li>Used a If statement with a condition that to store only the values which are of not a period(whitespace) type.</li>
<li>Stored all the values into output string using charAt() method</li>
</ul>
<pre class="brush: java; title: ; notranslate">
public class RemoveWhitespacesString {

	public static void main(String&#x5B;] args) {
		
		String str = &quot;Java is a programming language&quot;;
		char ch &#x5B;] = str.toCharArray();	
		String str3=&quot;&quot;;
		for(int i=0; i&lt;ch.length; i++)
		{
			if(ch&#x5B;i]!=' ')
			{
				str3 = str3 + str.charAt(i);
			}
			
		}
		System.out.println(str3);
		
	}
	
}
</pre>
<pre class="brush: java; title: ; notranslate">
Output:
-------
Javaisaprogramminglanguage
</pre>
<p><script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --></p>
<h3><strong><span style="color: #0000ff;">Method 3:</span></strong></h3>
<p><strong>Using replaceAll() method:</strong></p>
<p>In the below snippet, we have done the following:</p>
<ul>
<li>Created a string and assigned it with some value (includes whitespaces)</li>
<li>Created another string to store the output value</li>
<li>Using replaceAll() method with a regular expression which is a built-in method of string class we stored the value into the output string</li>
</ul>
<pre class="brush: java; title: ; notranslate">
public class RemoveWhitespacesString {

	public static void main(String&#x5B;] args) {
		
		String str = &quot;Java is a programming language&quot;;
		String str4=str.replaceAll(&quot; &quot;, &quot;&quot;);
		System.out.println(str4);
	}
	
}

</pre>
<pre class="brush: java; title: ; notranslate">
Output:
-------
Javaisaprogramminglanguage
</pre>
<p><script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<a href="https://www.youtube.com/watch?v=ZsmayCezAwo&amp;list=PL7BYd102yEfVz3OywzKWS5tFHGmkVRt9k&amp;index=2">Please watch the Youtube video for better understanding.</a><br />
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<div id="themify_builder_content-2181" data-postid="2181" class="themify_builder_content themify_builder_content-2181 themify_builder themify_builder_front">

	</div>
<!-- /themify_builder_content --><p>The post <a rel="nofollow" href="https://automationtesting.in/how-to-remove-whitespaces-from-a-string-in-java/">How to Remove Whitespaces from a String in Java</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://automationtesting.in/how-to-remove-whitespaces-from-a-string-in-java/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Perform Sum of the Digits in a Given Number in Java</title>
		<link>https://automationtesting.in/perform-sum-digits-given-number-java/</link>
					<comments>https://automationtesting.in/perform-sum-digits-given-number-java/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Mon, 11 Nov 2019 11:36:11 +0000</pubDate>
				<category><![CDATA[Java IQs]]></category>
		<category><![CDATA[Adding all the digits in a give number]]></category>
		<category><![CDATA[Sum of the digits]]></category>
		<category><![CDATA[sum of the digits in a given number]]></category>
		<category><![CDATA[sum of the digits in a number using java]]></category>
		<guid isPermaLink="false">http://automationtesting.in/?p=2208</guid>

					<description><![CDATA[<p>In this blog, we will learn about how to sum of the digits in a given number in Java. This will be asked in the most of the interviews.This can be implemented using the below way: In the below snippet, we have done the following: Created the below variables of int type Number (assigned it [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://automationtesting.in/perform-sum-digits-given-number-java/">How to Perform Sum of the Digits in a Given Number in Java</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
In this blog, we will learn about how to sum of the digits in a given number in Java. This will be asked in the most of the interviews.This can be implemented using the below way:</p>
<div class="post-video"><iframe loading="lazy" title="3. Sum of the Digits in a Given Number in Java  - Java Interview Questions" width="1165" height="655" src="https://www.youtube.com/embed/2JTPv0IW-no?wmode=transparent&#038;fs=1"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<p>In the below snippet, we have done the following:</p>
<ol>
<li>Created the below variables of int type
<ul>
<li>Number (assigned it with some value)</li>
<li>Sum (assigned it with some value)</li>
<li>Reminder</li>
</ul>
</li>
<li>By using while loop until the number value is greater than 0. we have done the below:
<ul>
<li>Performed modular division of the number and stored the result in the reminder</li>
<li>Stored the reminder value in the Sum</li>
<li>Performed Division operation of the number and stored the result in the Number</li>
</ul>
</li>
</ol>
<pre class="brush: java; title: ; notranslate">
public class SumOfDigitsInANumber {

	public static void main(String&#x5B;] args) {
	
		int number=2587, reminder, sum = 0;
		
		while(number&gt;0)
		{
			reminder = number % 10;
			sum = sum + reminder;
			number = number / 10;
		}
		System.out.println(&quot;The sum of digits in a given number is:&quot; +sum);
	}

}
</pre>
<pre class="brush: java; title: ; notranslate">
Output:
-------
The sum of digits in a given number is:22
</pre>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<p><a href="https://www.youtube.com/watch?v=2JTPv0IW-no&amp;list=PL7BYd102yEfVz3OywzKWS5tFHGmkVRt9k&amp;index=3">Please watch the Youtube video for better understanding.</a></p>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<div id="themify_builder_content-2208" data-postid="2208" class="themify_builder_content themify_builder_content-2208 themify_builder themify_builder_front">

	</div>
<!-- /themify_builder_content --><p>The post <a rel="nofollow" href="https://automationtesting.in/perform-sum-digits-given-number-java/">How to Perform Sum of the Digits in a Given Number in Java</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://automationtesting.in/perform-sum-digits-given-number-java/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Reverse a String in Java</title>
		<link>https://automationtesting.in/how-to-reverse-a-string-in-java/</link>
					<comments>https://automationtesting.in/how-to-reverse-a-string-in-java/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Mon, 04 Nov 2019 08:27:52 +0000</pubDate>
				<category><![CDATA[Java IQs]]></category>
		<category><![CDATA[how to reverse a string]]></category>
		<category><![CDATA[reverse a string]]></category>
		<category><![CDATA[reverse a string in java]]></category>
		<category><![CDATA[reverse a string using charAt method]]></category>
		<category><![CDATA[reverse a string using stringbuffer]]></category>
		<category><![CDATA[reverse a string using stringbuilder class]]></category>
		<category><![CDATA[string reverse]]></category>
		<guid isPermaLink="false">http://automationtesting.in/?p=2140</guid>

					<description><![CDATA[<p>In this blog, we will learn how to reverse a string in Java. This will be asked in the most of the interviews. This can be implemented in four different ways listed below: Convert String into Character Array and use For loop For loop with CharAt() method Using StringBuffer class Using StringBuilder class Method 1: [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://automationtesting.in/how-to-reverse-a-string-in-java/">How to Reverse a String in Java</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
In this blog, we will learn how to reverse a string in Java. This will be asked in the most of the interviews. This can be implemented in four different ways listed below:</p>
<ol>
<li>Convert String into Character Array and use For loop</li>
<li>For loop with CharAt() method</li>
<li>Using StringBuffer class</li>
<li>Using StringBuilder class</li>
</ol>
<div class="post-video"><iframe loading="lazy" title="1. How to Reverse a String in Java - Java Interview Questions (4 ways)" width="1165" height="655" src="https://www.youtube.com/embed/WaH_7In_HHk?list=PL7BYd102yEfVz3OywzKWS5tFHGmkVRt9k&#038;wmode=transparent&#038;fs=1"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --></p>
<h3><strong>Method 1:</strong></h3>
<p><strong>Convert String into Character Array and use For loop</strong></p>
<p>In the below snippet, we have done the following:</p>
<ul>
<li>Creating a new string and assigning a custom string value to it</li>
<li>Converting this string to character array using toCharArray() method</li>
<li>Calculating the length of character array and assigning it to a int variable.</li>
<li>Using for loop, we will iterate this to print the string in reverse</li>
</ul>
<pre class="brush: java; title: ; notranslate">

public class StringReverseDemo {

	public static void main(String&#x5B;] args) {

		String inputstring = &quot;Krishna&quot;;
		char&#x5B;] chars = inputstring.toCharArray();
		int length = chars.length;
		
		for (int i = length-1; i &gt;=0; i--) {
			System.out.print(chars&#x5B;i]);
			
		}

	}

}
</pre>
<h3><strong>Method 2:</strong></h3>
<p><strong>Convert String into Character Array and use For loop</strong></p>
<p>In the below snippet, we have done the following:</p>
<ul>
<li>Creating a new string and assigning a custom string value to it</li>
<li>Converting this string to character array using toCharArray() method</li>
<li>Calculating the length of character array and assigning it to a int variable.</li>
<li>Creating an another new string to concat the values to a brand new string</li>
<li>Using charAt() method, we will iterate this for loop to print the string in reverse and concat it to the newly created string</li>
</ul>
<pre class="brush: java; title: ; notranslate">
public class StringReverseDemo {

	public static void main(String&#x5B;] args) {
		
		String inputstring = &quot;Krishna&quot;;
		String revword = &quot;&quot;;
		char&#x5B;] chars = inputstring.toCharArray();
		int length = chars.length;
		
		for (int i = length-1; i &gt;=0; i--) {
			revword = revword+inputstring.charAt(i);
		}
		System.out.println(revword);

	}

}
</pre>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<h3><strong>Method 3:</strong></h3>
<p><strong>Using StringBuffer class</strong></p>
<p>We can use StringBuffer class to reverse a string value with help of its inbuilt methods directly as below:</p>
<pre class="brush: java; title: ; notranslate">

public class StringReverseDemo {

	public static void main(String&#x5B;] args) {
		
		String inputstring = &quot;Krishna&quot;;

		StringBuffer stringbuffer = new StringBuffer(inputstring);
		System.out.println(stringbuffer.reverse());
		
	}

}
</pre>
<h3><strong>Method 4:</strong></h3>
<p><strong>Using StringBuilder class</strong></p>
<p>We can use StringBuilder class to reverse a string value with help of its inbuilt methods directly as below:</p>
<pre class="brush: java; title: ; notranslate">

public class StringReverseDemo {

	public static void main(String&#x5B;] args) {
		
		String inputstring = &quot;Krishna&quot;;

		StringBuilder stringbuilder = new StringBuilder(inputstring);
		System.out.println(stringbuilder.reverse());
		
	}

}
</pre>
<p><ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<a href="https://www.youtube.com/watch?v=WaH_7In_HHk&amp;list=PL7BYd102yEfVz3OywzKWS5tFHGmkVRt9k">Please watch the Youtube video for better understanding.</a><br />
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<div id="themify_builder_content-2140" data-postid="2140" class="themify_builder_content themify_builder_content-2140 themify_builder themify_builder_front">

	</div>
<!-- /themify_builder_content --><p>The post <a rel="nofollow" href="https://automationtesting.in/how-to-reverse-a-string-in-java/">How to Reverse a String in Java</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://automationtesting.in/how-to-reverse-a-string-in-java/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Write Data in Excel Using Column Number in C#</title>
		<link>https://automationtesting.in/write-data-in-excel-using-column-number-in-c/</link>
					<comments>https://automationtesting.in/write-data-in-excel-using-column-number-in-c/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Thu, 26 Sep 2019 10:03:20 +0000</pubDate>
				<category><![CDATA[excel c#]]></category>
		<category><![CDATA[data driven testing using excel c#]]></category>
		<category><![CDATA[excel operations in c#]]></category>
		<category><![CDATA[how to interact with excel]]></category>
		<category><![CDATA[set data in excel]]></category>
		<category><![CDATA[set data in excel using column number]]></category>
		<category><![CDATA[using column number to write data]]></category>
		<guid isPermaLink="false">http://automationtesting.in/?p=2097</guid>

					<description><![CDATA[<p>Write data in excel using column number in C#, We will discuss about how to write data in excel using column number in C#. Usually we will use the excel sheet to maintain the test data. We might get doubt that why we need to put the test data/results in excel. If an application feed [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://automationtesting.in/write-data-in-excel-using-column-number-in-c/">Write Data in Excel Using Column Number in C#</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img src='http://automationtesting.in/wp-content/uploads/2019/09/WRITE-DATA-TO-EXCEL-USING-COLUMN-NUMBER-Using-C.png'></p><p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
Write data in excel using column number in C#, We will discuss about how to write data in excel using column number in C#. Usually we will use the excel sheet to maintain the test data. We might get doubt that why we need to put the test data/results in excel. If an application feed so much of data to be need to test; then we will manage those data using external sources like text file, xml file and excel file etc…. Among these; Excel is very user friendly that we can organize the data very easily and we can read and write the data how we want. So, we mostly use excel to maintain the test data and results.</p>
<div class="post-video"><iframe loading="lazy" title="5. How to Write Data To Excel using Column Number in Selenium Webdriver C# | Excel Write in C#" width="1165" height="655" src="https://www.youtube.com/embed/FKcuPiLxIik?wmode=transparent&#038;fs=1"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p>So, if you want to write huge number of test data in excel sheet to feed to the application then we need to know how many rows and columns are there in the excel. If you know exact information about the test data then only we can get the information from the excel in proper way. In this blog we will use to write data in excel using column number in C#. To do this, we need to create a console application in Visual studio and Install Microsoft.Office.Interop.Excel Nuget package.</p>
<p>For this we need to have the below pre-requisites:</p>
<ol>
<li style="font-weight: 400;"><span style="font-weight: 400;">Create a Console Application in Visual Studio</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Install </span><b>Microsoft.Office.Interop.Excel</b><span style="font-weight: 400;"> Nuget Package by following below steps</span>
<ul>
<li style="font-weight: 400;"><span style="font-weight: 400;">Under your Console Application, Right Click on reference, Click on Manage Nuget Package </span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Go to Browse</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Under Browse search for “Microsoft.Office.Interop.Excel” </span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">click on “Microsoft.Office.Interop.Excel” and then Click Install</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Make sure that your package got installed and appears under References folder under your Console App.</span></li>
</ul>
</li>
</ol>
<p><b>What is Microsoft.Office.Interop.Excel Nuget package?</b></p>
<p>By using this Nuget package we can interact with the excel like reading data from the Excel or writing data to the excel.</p>
<p>To Interact with our Nuget, we need to add the below using statement:</p>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<p><b>Using xl = Microsoft.Office.Interop.Excel;</b></p>
<p><b>Below are the classes will use to write the column number:</b></p>
<ol>
<li style="font-weight: 400;"><span style="font-weight: 400;">ExcelApiTest</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">CheckExcel</span></li>
</ol>
<p><b>Below are the Interfaces will use to Set the cell data using Microsoft.Interop.Excel package:</b></p>
<ol>
<li style="font-weight: 400;"><span style="font-weight: 400;">Xl.Application</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Xl.Workbooks</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Xl.Workbook</span></li>
</ol>
<p><b>Below collection is needed to create a Hash table:</b></p>
<ol>
<li><span style="font-weight: 400;">Using System.Collections</span></li>
</ol>
<p><b>Below Constructors are called to Interact with the User defined Excel sheet:</b></p>
<ol>
<li style="font-weight: 400;"><span style="font-weight: 400;">ExcelApiTest</span></li>
</ol>
<p><b>Below are the Methods will use to set the cell data using column number:</b></p>
<ol>
<li style="font-weight: 400;"><span style="font-weight: 400;">OpenExcel() //Establish the connection</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">CloseExcel()//Closes all the connections</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">SetCellData()</span></li>
</ol>
<p>Following is the code, we have used some Interfaces and methods to create connections, setting the cell data using column number and closing the connections.</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.Collections;
using System.Runtime.InteropServices;
using xl = Microsoft.Office.Interop.Excel;

namespace CSharpPractice
{
    class ExcelApiTest
    {
        xl.Application xlApp = null;
        xl.Workbooks workbooks = null;
        xl.Workbook workbook = null;
        Hashtable sheets;
        public string xlFilePath;

        public ExcelApiTest(string xlFilePath)
        {
            this.xlFilePath = xlFilePath;
        }

        public void OpenExcel()
        {
            xlApp = new xl.Application();
            workbooks = xlApp.Workbooks;
            workbook = workbooks.Open(xlFilePath);
            sheets = new Hashtable();
            int count = 1;
            // Storing worksheet names in Hashtable.
            foreach (xl.Worksheet sheet in workbook.Sheets)
            {
                sheets&#x5B;count] = sheet.Name;
                count++;
            }
        }

        public void CloseExcel()
        {
            workbook.Close(false, xlFilePath, null); // Close the connection to workbook
            Marshal.FinalReleaseComObject(workbook); // Release unmanaged object references.
            workbook = null;

            workbooks.Close();
            Marshal.FinalReleaseComObject(workbooks);
            workbooks = null;

            xlApp.Quit();
            Marshal.FinalReleaseComObject(xlApp);
            xlApp = null;
        }

        public bool SetCellData(string sheetName, int colNumber, int rowNumber, string value)
        {
            OpenExcel();

            int sheetValue = 0;

            try
            {
                if (sheets.ContainsValue(sheetName))
                {
                    foreach (DictionaryEntry sheet in sheets)
                    {
                        if (sheet.Value.Equals(sheetName))
                        {
                            sheetValue = (int)sheet.Key;
                        }
                    }

                    xl.Worksheet worksheet = null;
                    worksheet = workbook.Worksheets&#x5B;sheetValue] as xl.Worksheet;
                    xl.Range range = worksheet.UsedRange;

                    range.Cells&#x5B;rowNumber, colNumber] = value;

                    workbook.Save();

                    Marshal.FinalReleaseComObject(worksheet);
                    worksheet = null;
                    CloseExcel();
                }
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }
}
</pre>
<p>Below is a sample program which will call the methods from the above program to set the cell data using column number from any excel sheet.</p>
<pre class="brush: csharp; title: ; notranslate">
using System;

namespace CSharpPractice
{
    class CheckExcel
    {
        static void Main(string&#x5B;] args)
        {
            string xlFilePath = &amp;quot;D:/ExcelFiles/TestData.xlsx&amp;quot;;

            ExcelApiTest eat = new ExcelApiTest(xlFilePath);

            eat.SetCellData(&amp;quot;Credentials&amp;quot;, 5, 5,&amp;quot;FAIL&amp;quot;);

        }

    }
}
</pre>
<p><a href="https://youtu.be/FKcuPiLxIik">Please watch the Youtube video for better understanding.</a></p>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<!-- Responsive --><br />
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-9173866185064071" data-ad-slot="6638633547" data-ad-format="auto"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<div id="themify_builder_content-2097" data-postid="2097" class="themify_builder_content themify_builder_content-2097 themify_builder themify_builder_front">

	</div>
<!-- /themify_builder_content --><p>The post <a rel="nofollow" href="https://automationtesting.in/write-data-in-excel-using-column-number-in-c/">Write Data in Excel Using Column Number in C#</a> appeared first on <a rel="nofollow" href="https://automationtesting.in">Selenium Webdriver Appium Complete Tutorial</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://automationtesting.in/write-data-in-excel-using-column-number-in-c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
