http://prntscr.com/a3hg8q CALCULATOR Objects, Classes and Methods
------- Reading User Input from Console------------
1)
a http://prntscr.com/a3hpw5 b http://prntscr.com/a3hq7k
2)
a http://prntscr.com/a3htzi b http://prntscr.com/a3hu71
3) compute total
http://prntscr.com/a3hwi5
4)count matches
http://prntscr.com/a3hxcw
5) find first matches
http://prntscr.com/a3hxu0
-------------------------- Arrays and ---------------------------
sum of arrays
http://prntscr.com/a3i4kh
min max and average of score
a http://prntscr.com/a3i5il b http://prntscr.com/a3i5r3 c http://prntscr.com/a3i5wx
student with min/max score .. average of class and print their name of max and low student score
a http://prntscr.com/a3i7qs b http://prntscr.com/a3i8az http://prntscr.com/a3i8ix c http://prntscr.com/a3i91z
simple 2 dimensional array
http://prntscr.com/a3ia1o
------------------------- ArrayList -------------------------
0
public static void main(String[] args) {
String[] stuffArray = {"foo","bar","baz","boz","gaz","goz"};
ArrayList<String> stuff = new ArrayList<String>();
stuff.addAll(Arrays.asList(stuffArray));
for (int i = 0; i < stuff.toArray().length; i++)
System.out.println(stuff.toArray()[i]);
}
1
List myList = new ArrayList();
String[] myStringArray = new String[] {"Java", "is", "Cool"};
Collections.addAll(myList, myStringArray);
3 remove / get from position/ print
http://www.homeandlearn.co.uk/java/images/java_2015/arrays/ArrayList.gif
4
// create an array list
ArrayList al = new ArrayList();
System.out.println("Initial size of al: " +
al.size());
// add elements to the array list
al.add("C");
al.add("A");
al.add("E");
al.add("B");
al.add("D");
al.add("F");
al.add(1, "A2");
System.out.println("Size of al after additions: " +
al.size());
// display the array list
System.out.println("Contents of al: " + al);
// Remove elements from the array list
al.remove("F");
al.remove(2);
System.out.println("Size of al after deletions: " +
al.size());
System.out.println("Contents of al: " + al);
4) compare http://beginnersbook.com/2013/12/how-to-compare-two-arraylist-in-java/
5) merge/print 2 arraylist
6) find position http://beginnersbook.com/2013/12/java-arraylist-indexof-method-example/
7) clone http://beginnersbook.com/2013/12/how-to-clone-an-arraylist-to-another-arraylist/
8) checking the specified element
9) emty/clear and array http://beginnersbook.com/2013/12/how-to-empty-an-arraylist-in-java/
10) find size http://beginnersbook.com/2013/12/how-to-find-length-of-arraylist-in-java/
11) check if is emty boolean result = stringList.isEmpty(); //return true if List is empty
if(stringList.size() == 0){
System.out.println("ArrayList is empty");
}
12 iterator http://tutorialspointexamples.com/arraylist-in-java/
----------------------PRIME nUMBER / FOR LOOP--------------------
http://prntscr.com/a3hvad
COMPARE sTRINGS
http://prntscr.com/a3ht4x
Random number
http://prntscr.com/a3hyq0
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.