for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j+"*"+i+"="+(i*j)+"\t");
}
System.out.println("\n");
}
int temp;
int[] arrays={8,5,2,9,6,7};
int count = 0;
for (int i = 0; i < arrays.length; i++) {
boolean flag = false ;
for(int j = 0;j < arrays.length-1 -i ;j++){
if ( arrays[j+1]<arrays[j]){
temp =arrays[j];
arrays[j]=arrays[j+1];
arrays[j+1] = temp;
flag = true;
System.out.println(Arrays.toString(arrays));
}
}
}
package com.Test;
import java.util.*;
public class ArrayListTest {
public static void main(String[] args) {
ArrayList list = new ArrayList();
list.size();
list.add(5);
list.add(5);
list.add(1);
list.add(8);
list.add(7);
int count1= 0;
int count= 0;
ArrayList temp = new ArrayList(list.size());
Integer[] arr = { 1, 1, 2, 3 };
Integer[] tmp = new Integer[arr.length];
for (int i = 0; i < arr.length; i++) {
count++;
for (int n = 0; n < tmp.length; n++) {
count1++;
if (tmp[n] == arr[i]) {
}
}
}
System.out.println(count);
System.out.println(count1);
}
public static void duplicateRemovalByList(String [] arrStr) {
List<String> list = new ArrayList<String>();
for (int i=0; i<arrStr.length; i++) {
if(!list.contains(arrStr[i])) {
list.add(arrStr[i]);
}
}
String[] newArrStr = list.toArray(new String[1]);
System.out.println(Arrays.toString(newArrStr));
}
public static void duplicateRemovalByMap(String [] arrStr) {
Map<String, Object> map = new HashMap<String, Object>();
for (String str : arrStr) {
map.put(str, str);
}
String[] newArrStr = map.keySet().toArray(new String[1]);
System.out.println(Arrays.toString(newArrStr));
}
public static void duplicateRemovalByLink(Object[] arr){
LinkedHashSet<Object> link = new LinkedHashSet<Object>();
for (int i = 0; i < arr.length; i++) {
link.add(arr[i]);
}
Iterator<Object> iterator = link.iterator();
System.out.println(link);
}
}