Converting String Array to Integer Array Example Java

Java Program to Convert String Array to Integer Array: In this below program we have converted string array to integer array. package in.javadomain; public class StringArrayToIntArray { public static void main(String[] args) { String[] strArray = { "10", "20", "30", "40", "50" }; int[] intArray = new int[strArray.length]; for (int i = 0; i < strArray.length; i++) { intArray[i] =

168 total views, no views today

» Read more

Java Program to find two letter capital words using Regex

Java Program to find two letter capital words in Java using Regex: import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexAppealAddress { public static void main(String[] args) { String input = "Javadomain is also called as JD which contains JAVA tutorials and programmings"; // This prints JD and JA // Pattern regexPattern = Pattern.compile("\\s[A-Z]{2,2}"); // This prints only JD Pattern regexPattern =

96 total views, 1 views today

» Read more

Arraylist vs LinkedList Java

ArrayList Vs LinkedList: ArrayList: 1. Search operation is faster, because it maintains the array structure, so get(index) will search and give the value fastly. 2. Less memory consumption because it maintains element and data. Where in linkedlist it maintains two pointer to store the addresses of the neighbour elements. LinkedList: 1. Remove operation is faster. 2. Insertion operation is faster.

103 total views, no views today

» Read more

Finding difference in java example:

Java program to find the difference: Takes array of integer inputs and finding the difference package in.javadomain; public class FindDifference { public static void main(String[] args) { // inputs here int[] i = { 1,11,21,31 }; int temp = i[1] – i[0]; int k = 1; int lastValue = i[i.length – 1]; boolean logicCheck = false; boolean wrongLogic = true;

93 total views, 1 views today

» Read more

Removing some values from the List in Java Example

Remove one List value from another list: Java Program to Remove List Values from another List values: In this program we are deleting the list2 values from list1. package in.javadomain; import java.util.ArrayList; import java.util.List; public class RemoveListValue { public static void main(String[] args) { List<String> myList1 = new ArrayList<String>(); myList1.add("Java"); myList1.add("PHP"); myList1.add("C"); List<String> myList2 = new ArrayList<String>(); myList2.add("Java"); myList2.add("PHP"); System.out.println("List

88 total views, no views today

» Read more

Java Regex Pattern to allow characters and spaces Example

Java Regex Pattern to allow characters and spaces Example: Requirements: Java domain – Should be allowed – Should Not allowed Java – Should be allowed (Java) – Should Not allowed Javadomain – Should be allowed Java Regex Program to allow characters and whitespaces And also not allow only whitespaces: import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexSpace { public static void

165 total views, no views today

» Read more

Finding Common values in Arraylist Java Example

Finding Common values in Arraylist: Two arraylists are iterated one inside another for loop and common values are inserted in the common arraylist. Input: List 1 contains: God .Net PHP Java List 2 contains: C Java C++ .Net Expected Values: Common values are :::Java Common values are :::.Net Java Program to Find Common values in Arraylist: import java.util.ArrayList; import java.util.List;

300 total views, 19 views today

» Read more

Compare Three List in Java Example

Arraylist/List comparison in Java: Now we have a scenario to split three list/arraylist values to seven lists with respect to list/arraylist values. Input: List 1 contains: Java PHP 26 God List 2 contains: C Java PHP List 3 contains: 26 Guru C Java Expected Output: only in list 1 ::: God only in list 2 ::: only in list 3

270 total views, 1 views today

» Read more

Java Regex Pattern Example

Regex [Regular Expression]: Regular expression is a useful one to match and extract only the required parts. Eg: Defining the phone number formats. Removing unreadable or unwanted characters from a string Sample Program: import java.util.regex.Matcher; import java.util.regex.Pattern; public class Regex { public static void main(String[] args) { String inputStr = "?Javadomain.in’s a technical,java-blog"; Pattern pattern = Pattern.compile("[\\s\\?\\,\\-\\’]+"); Matcher matcher =

141 total views, no views today

» Read more

PDF Scrapping in Java Sample code

PDF Scrapping: We may needed to scrap the pdf using java. This involves parsing tables and different areas of pdf. How can we proceed ? We can proceed this way, 1. Converting pdf to html/xml 2. Parsing the converted html/xml using the Jsoup open source Jar (Jsoup-1.7.2). Converting pdf to html: To convert pdf to html we can use pdfbox

186 total views, 1 views today

» Read more