课程: Java for All Platforms: Desktop, Web, and Mobile Development

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Arrays and lists

Arrays and lists

- [Instructor] Arrays are a key staple of any programming language and of course, Java is no different. If you're unfamiliar with arrays you can think of them as a numbered list of items. Each item has its associated numeric slot starting with zero and then going up. So let's say we want to create an array of strings. Type the keyword String with a capital S and we say that this is a string array by typing square brackets after the array's data type. Follow that with the name of the array. So I'll call this myArray. And then one way to create an array is to use the new keyword and then String and square brackets followed by a semicolon. When you create an array in Java, you actually need to know how many items are going to be in the array. So let's say I'm going to put three items in the array. I put a three in the brackets there. So that's saying create a new three item array that will hold only strings. So go to…

内容