Liaoliang Pro-Biography "DT Big Data DreamWorks" third speaking of tuple, Array, map and file operation Introduction Combat

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.