Start learning now
You've leveled up!
Still wondering if getting into the IT field is worth the effort? CodeGym's super motivational specialist has collected lots of interesting facts and figures to dispel your doubts. The growth rate of the IT sector of the economy and the Internet, immigration opportunities, and IT professionals' salaries. This is a motivational lecture.
Usually one family lives in a private house, but an apartment building accommodates many. To send a letter to a family living in a private home, you need to provide a house number. But writing a letter to a family that lives in an apartment complex also requires an apartment number. An array variable is like an "apartment" variable. Arrays are super useful structures. It's time to study them!
Arrays in memory
An array is an ordered set of elements. It's like in an apartment building: each apartment has its own number. An array doesn't actually contain the apartments. Instead, it contains their numbers (that is, references to them). Clear as mud? Your mentor will explain everything! This lesson is about how arrays are arranged in memory and how we can live with it.
Basic actions with arrays
Working with arrays is easy. You just need to get used to the fact that we have not one element, but several, with a single identity. So let's take a look at some popular examples and consider how to populate arrays, initialize them, display them, and search for the smallest element. This knowledge is very useful for understanding programming as such.
Practice creating and using arrays
It's time to tackle some interesting tasks about arrays. Otherwise, your knowledge will become meaningless, like the life of a bank clerk in a matrix... By the way, did you know that the matrix is an array? Only people familiar with the mathematical definition of a matrix will get a kick out of that. Let's reinforce the concept of arrays, and do (a few) more tasks.
For a beginner, the ArrayList class is aerobatics! This topic usually comes much later, but here at the secret CodeGym center we decided not to drag out the Cat cat = new Cat() by the tail. So we created an overview of ArrayLists for the very first quest. Here we'll try to explain what kind of class ArrayList is and compare it with ordinary arrays.
Practice with ArrayList
We're strictly adhering to the methodology adopted by the secret CodeGym training center: learn information and then practice using it. The now incomprehensible and complex phrase ArrayList<String> list = new ArrayList<>() will soon become instinctive and clear. As plain as «Hello, I'm a list of strings. You can call me 'list'».
What are generics?
According to Wikipedia, a generic is a drug sold under an international non-proprietary name or under a proprietary name different from the brand name. In Java, generics… Uh...are in no way related to generic drugs. They're just types with a parameter.
Examples using ArrayList and generics
You will be fully immersed in Java generics and ArrayList during your second quest at the secret CodeGym center. But right now we'll slow become accustomed to these complex but essential structures, analyzing code snippets with detailed explanations from your teachers.
Practice with lists
According to research performed by the secret CodeGym center in academic year 3099, ArrayList appears to be the most difficult topic for the students working on the first quest. One of... So don't idle your time away: take the bull by the horns and start completing tasks. The more tasks you do, the clearer ArrayList will become.
Useful links from the Professor – 7
Primitives and wrappers... The Collections class... String manipulation methods... Removing items from a list and the ConcurrentModificationException... The professor has done a great job and found a lot of interesting materials that cover these topics and much more. Don't skip them and your knowledge of Java will be smooth and silky!
House of Codes
As you complete the intense seventh level, you need a proper rest. Relaxation experts say changing your routine is the best way to achieve this. Before tackling the tasks at the very end of the level, watch a teaser trailer for the epic House of Codes. You might not yet fully realize what power you possess in your tender Java-programmer fingers. :)