This video covers adding Arrays to your code. In Scala, you can create a collection of values using an Array. The downside must to set to a fixed size, so if you need a variable size array, you can use an ArrayBuffer, an ArrayBuffer is similar to an ArrayList in Java or a vector in C++.
- [Narrator] In Scala, we can create…a collection of values using an array.…The downside of an array is that…it must be set to a fixed size.…So if we need a variable size array,…we can use an array buffer.…An array buffer is similar to an array list in Java…or even a vector in C++.…Alright, let's take a look at some examples.…Let's add a worksheet, so I'm going…to open up my package explorer, I'm going to right-click…on my worksheet example project SRC package folder,…and I'm going to say new Scala worksheet,…and I'm going to call it array example.…
I'm going to delete the print line statement,…and now we're ready to get started.…When we create an array, we're only…going to use the keyword "new"…if we are not initializing it at the same time.…So let's do that first, let's create a variable…called nums and set it equal to an array.…So this time I have to say "new" array.…I'm going to give it a data type.…I'm going to give it the data type "any"…because that way it can be a number, a string, boolean, etc,…and I need to give it a size.…
Join Peggy Fisher as she helps get you started with Scala, so you can leverage the unique capabilities it offers. First, learn the basics of type inference, variables, loops, functions, and operators. Then, find out how to read files using a console, perform pattern matching, handle exceptions, and more. Finally, learn how to use classes, fields, methods, and objects.
- Integrating with IDEs
- Scala worksheets
- Scala repl sessions
- Type inference
- Creating variables
- Working with loops
- Higher-order functions
- Scala operators
- Working with decision statements
- Handling exceptions using try or catch
- Working with tuples and arrays
- Classes, fields, and methods
Skill Level Intermediate
Java Platforms Compared: SE vs EE vs MEwith Peggy Fisher25m 38s Intermediate
Scala Essential Training for Data Sciencewith Dan Sullivan1h 51m Intermediate
1. Getting Started with Scala
2. Scala Basics
3. More Scala Basics
4. Objects with Scala
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.