Liaoliang Pro-Biography "DT Big Data DreamWorks" third speaking of tuple, Array, map and file operation Introduction Combat
Do you want to know big data, do you want to be a yearly salary million? So what are you waiting for, come on! Follow Liaoliang's teacher to learn spark big data
The third is about tuple, Array, map and file operation introduction
Tuple
Object Tupleops {
def main (args:arrag[string]): Unit = {
Val triple = (+, "Scala", "Spark")
Printin (triple._1)
Printin (triple._2)
}
}
Array
Object Arrayoperations {
def main (args:arrag[string]): Unit = {
Val Array = array (1,2,3,4,5)
For (I <-0 until Array.Length) {
Printin (Array (i))
}
Another way of writing
For (elem <-array) {
Printin (Elem)
}
}
Map
Object Mapoperations {
def main (args:arrag[string]) {
Val ages = Map ("Rocky", "Spark", 5)
For ((K,V) <-ages) {
Printin ("Key is" + K + ", value is" + V)
}
For ((k,_) <-ages) {//placeholder
Printin ("Key is" + k)
}
}
}
File operations
Object Fileops {
def main (args:arrag[string]) {
Val file = Source.fromfile ("F:\\tuiguangneirong.docx")
Val file = Source.fromurl ("http://www.hiwifi.com")
for (line <-file.getlines) {
Printin (line)
}
}
}
The basic understanding of tuple (simple usage of tuples), array (array simple usage), MAP (key and value two values), and file base operations is based on a simple code example. I hope I follow the teacher to learn 1.1 points of progress;
If you know it's unclear, you can also learn this video or record the contact information
Video Address: http://www.tudou.com/programs/view/hqRFiGUlP4M/
Study Address: http://mp.weixin.qq.com/s?__biz=MzAwNjAwODI3Mg==&mid=212579488&idx=2&sn= 883193df2b3df163d49c4fdec1ecd585&scene=5#rd
Liaoliang Pro-Biography "DT Big Data DreamWorks" third speaking of tuple, Array, map and file operation Introduction Combat