{vView}{vViewLabel}{vViewValueStyle}
{vViewValue}{/vViewValue}
{vView}{hView}
{vViewLabel}Part No.{/vViewLabel}
{vView}
{vViewValueStyle}font-weight: bold;TEXT_IMPORTANT{/vViewValueStyle}
It is my Computer Notes. Using Guide : object-key or object-key-key e.g. Step 1 Blog Search : [mysql-run] and then Step 2 ctrl+F [mysql-run] {bookMark me : Ctrl+D}
Array at beginning: | 84 | 69 | 76 | 86 | 94 | 91 |
After Pass #1: | 84 | 91 | 76 | 86 | 94 | 69 |
After Pass #2: | 84 | 91 | 94 | 86 | 76 | 69 |
After Pass #3: | 86 | 91 | 94 | 84 | 76 | 69 |
After Pass #4: | 94 | 91 | 86 | 84 | 76 | 69 |
After Pass #5 (done): | 94 | 91 | 86 | 84 | 76 | 69 |
While being an easy sort to program, the selection sort is one of the least efficient. The algorithm offers no way to end the sort early, even if it begins with an already sorted list.
// Selection Sort Method for Descending Orderpublic static void SelectionSort ( int [ ] num )
|
package com.tutorialspoint; import java.util.Arrays; import java.util.List; public class ArrayDemo1 { public static void main (String args[]) { // create an array of strings String a[] = new String[]{"abc","klm","xyz","pqr"}; List list1 = Arrays.asList(a); // printing the list System.out.println("The list is:" + list1); } }
The list is:[abc, klm, xyz, pqr]
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
public class StringArrayTest
{
public static void main(String[] args)
{
String[] words = {"ace", "boom", "crew", "dog", "eon"};
List<String> wordList = Arrays.asList(words);
for (String e : wordList)
{
System.out.println(e);
}
}
}
List<String> stockList = new ArrayList<String>();
stockList.add("stock1");
stockList.add("stock2");
String[] stockArr = new String[stockList.size()];
stockArr = stockList.toArray(stockArr);
for(String s : stockArr)
System.out.println(s);
package com.tutorialspoint; import java.util.ArrayList; public class ArrayListDemo { public static void main(String[] args) { // create an empty array list with an initial capacity ArrayList<Integer> arrlist = new ArrayList<Integer>(5); // use add() method to add elements in the list arrlist.add(15); arrlist.add(22); arrlist.add(30); arrlist.add(40); // let us print all the elements available in list for (Integer number : arrlist) { System.out.println("Number = " + number); } // retrieves element at 4th postion int retval=arrlist.get(3); System.out.println("Retrieved element is = " + retval); } }
Number = 15 Number = 22 Number = 30 Number = 40 Retrieved element is = 40
private int[] buildIntArray(List<Integer> integers) {
int[] ints = new int[integers.size()];
int i = 0;
for (Integer n : integers) {
ints[i++] = n;
}
return ints;
}
List<Integer> list = Arrays.asList(1, 2, 3);
int[] array = { 1, 2, 3 };
ArrayList<Integer> list = new ArrayList<Integer>(array.length);
for (int i = 0; i < array.length; i++)
list.add(Integer.valueOf(array[i]));