How to make Array List Thread Safe(Synchronised) in Java

import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; public class ThreadeSafeArrayList { public static void main(String[] args) { List<String> list=new ArrayList<String>(); list.add(“A”); list.add(“B”); list.add(“C”); list.add(“D”); list.add(“E”); list.add(“F”); list= Collections.synchronizedList(list); synchronized (list) { for (String str:list) { System.out.println(str); } } } }

How to Remove Duplicate Object from ArrayList in Java

import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; public class RemoveDuplicate { public static void main(String[] args) { List<Integer> list = new ArrayList<>(); list.add(101); list.add(158); list.add(136); list.add(120);// Duplicate Object list.add(120); list.add(101); // Itrate all data for (Integer i : list) { System.out.println(i); } System.out.println(“——————————————-“); Set<Integer> set = new LinkedHashSet<>(list); // Itrate Unique Data for (Integer[…]

how Insert data in mysql using java

import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.Scanner; public class Insert { public static void main(String[] args) throws ClassNotFoundException { // Class.forName(“”); Class.forName(“com.mysql.jdbc.Driver”); Connection con=null; try { con= DriverManager.getConnection(“jdbc:mysql://localhost:3306/tss_db”, “root”, “”); Statement s= con.createStatement(); Scanner s1=new Scanner(; System.out.println(“Enter Your name”); String name=; System.out.println(“Enter Your Age”); int age= s1.nextInt(); System.out.println(“Enter Your Mobile”); String[…]

How to create dynamic string in java with the help of Map

public class Util { public static String str=”your name is ${SD} u r working in ${CN}”; public static void main(String[] args) { Map<String, String> map=new HashMap<String, String>(); map.put(“SD”, “Rakesh”); map.put(“CN”, “Tss Infotech”); Set<Entry<String, String>> set=map.entrySet(); String string=””; for (Iterator iterator = set.iterator(); iterator.hasNext();) { Entry<String, String> entry = (Entry<String, String>); String key= entry.getKey(); string=str.replace(“${“+key+”}”,[…]