Created
February 8, 2016 14:39
-
-
Save srigalamilitan/a42066ca8e2941655f6a to your computer and use it in GitHub Desktop.
Example HashBasedTable see www.putracode.com to see more explanation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.putracode.guava.collections; | |
import com.google.common.collect.HashBasedTable; | |
import com.google.common.collect.Table; | |
import static com.putracode.guava.Util.printTitle; | |
import static com.putracode.guava.Util.println; | |
/** | |
* Created by KrisnaPutra on 2/8/2016. | |
*/ | |
public class GuavaHashBasedTable { | |
public static void main(String[] args) { | |
Table<Long,String,Object> hashBaseTables=HashBasedTable.create(); | |
//Row One | |
hashBaseTables.put(1l,"First Name",new String("Krisna")); | |
hashBaseTables.put(1l,"Last Name",new String("Putra")); | |
hashBaseTables.put(1l,"Age",new Integer(28)); | |
//Row Two | |
hashBaseTables.put(2l,"First Name",new String("Dira")); | |
hashBaseTables.put(2l,"Last Name",new String("Safitri")); | |
hashBaseTables.put(2l,"Age",new Integer(25)); | |
//Row Three | |
hashBaseTables.put(3l,"First Name",new String("Nagita")); | |
hashBaseTables.put(3l,"Last Name",new String("Wishly")); | |
hashBaseTables.put(3l,"Age",new Integer(1)); | |
printTitle("Google Guava : HashBaseTable"); | |
println("Select * from Student Table : "+hashBaseTables); | |
println("Select * from Student Table Where Row=1 -->"+hashBaseTables.row(1l)); | |
println("Select First Name from Student Table where Row=2 -->"+hashBaseTables.get(2l,"First Name")); | |
println("Select * from Student Table Where Row=3 -->"+hashBaseTables.row(3l)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment