BeginnersJava.com -- Java- Lesson 15b -- Arrays continued

preview_player
Показать описание
Source Code available here:

Also: Alabama, Alaska, Arizona, Arkansas, California, Colorado, Connecticut, Delaware, Florida, Georgia, Hawaii, Idaho, Illinois, Indiana.... I can't believe I couldn't get that during the video...
Рекомендации по теме
Комментарии
Автор

Well, ArrayLists are a type too, so it's not really a 'flaw' in so much as it being a feature. Php is a soft-typed language with TONS of security holes and error conditions. That's the basic tradeoff. When you get into Hard-typed OOP like this, there is more concern about memory (java handles for you) and how that memory is allocated. Variable sized containers typically start with a static-sized container and destory / rebuild as you add elements in many cases (c++ vector does, ? about java)

BeginnersProgramming
Автор

He is probably looking for an ArrayList solution. But Vector is a valid data type in Java too!

GeorgiySlobodenyuk
Автор

Unfortunately that is something that doesn't exist*. Arrays are made to be fixed size storage sets. You can make one however large you want with int anArray[] = new Array[x] where x= whatever number you want, but once you set that number, you're toast. You can write yourself a method to increase the size of anArray by killing off the reference to it, but that would be hard. Your best bet would be to look at an "ArrayList" which is a lot like a C++ Vector...

BeginnersProgramming
Автор

ideone (dot )com/wG9j7 for the rest of my answer.

BeginnersProgramming
Автор

Vector is NOT a valid type, it's

BeginnersProgramming
join shbcf.ru