Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Scala<br />
}<br />
println("Total is " + total);<br />
// Finding the largest element<br />
var max = myList(0);<br />
for ( i max) max = myList(i);<br />
}<br />
println("Max is " + max);<br />
}<br />
}<br />
Save the above program in Demo.<strong>scala</strong>. The following commands are used to compile and<br />
execute this program.<br />
\><strong>scala</strong>c Demo.<strong>scala</strong><br />
\><strong>scala</strong> Demo<br />
Output<br />
1.9<br />
2.9<br />
3.4<br />
3.5<br />
Total is 11.7<br />
Max is 3.5<br />
Scala does not directly support various array operations and provides various methods to<br />
process arrays in any dimension. If you want to use the different methods then it is required<br />
to import Array._ package.<br />
Multi-Dimensional Arrays<br />
There are many situations where you would need to define and use multi-dimensional arrays<br />
(i.e., arrays whose elements are arrays). For example, matrices and tables are examples of<br />
structures that can be realized as two-dimensional arrays.<br />
100