Hi I am a student finished AP CSA and taught myself abstraction, hashMaps, enums, switches, exceptions, and a bit of files, I am trying to use the roadmap.sh but it confuses me, is there really any point of learning any data structures after arrays multi dimensional arrays, Arraylist, and hashMaps? If so when should I learn them and what should I be working on now as a beginner? I definitely need to move more to newer java as I am starting to get Java 21 but refuse to use the var keyword
#Data structures and learning
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
There is a reason to learn other data structures. Queues, stacks, sets, trees
its good to know what they are
Also if you want to get a job, everyone will give you DSA coding interview
depends where you are from mostly
in germany that isnt that much of a thing compared to US or others
yeah, caracalsam basically mentioned the big ones: queues, sets etc..
var is just a handy tool to reduce boilderplate
for(List<List<String>> list : lists) {
}```
VS
```java
for(var list : lists) {
}```
i'd recommend focusing on learning common frameworks, if you're looking into how to improve your ability to contribute
knowing the language is useful, but knowing frameworks is whats going to get you by
In this are you iterating through a “2d Arraylist” or an arraylist of lists
list, not necessarily arraylist
but yes. iterating through a list of lists
the point was rather that u can use var in cases where the type is obvious to the reader
same as here:
var house = new House();
its debatable how far u should take this though. stuff like this shouldnt be done:
var foo = john.eat(banana);
(its totally unclear to a reader what this var foo is)
So can var technically be used for runtime polymorphism
Var i = 5; var obj = new Clock(); Arraylist<var> list = new Arraylist<>(); list.add(i);
list.add(obj);
no
var is nothing but syntax sugar
its not a new type or anything
the compiler immediately replaces it by the type induced from the context
when u write var dog = new Dog(); this is instantly replaced internally by Dog dog = new Dog();
u can do that already by simply using Object
int i = 5;
Clock clock = new Clock();
List<Object> anything = new ArrayList<>();
anything.add(i);
anything.add(clock);
Yes I know that but just to make sure the object class is abstract and not an interface correct?
its neither. its a normal class which all other classes (implicitly) extend from
when u write
class Foo {
...
}
ur technically writing
class Foo extends Object {
...
}
Object itself is a normal class
u could in theory also create instances of it
new Object()
Oh I was taught that every class extends it but it cannot be made
there isnt really any magic to it. its a totally normal java class 👍
just some java code someone wrote
it probably should have been made an abstract class, but nope
Object o = new Object();
There's reasons to have bare objects
Not a lot of good ones anymore, but def reasons
What reasons the only methods are tostring and equals right?
Well - there are some other methods too. Dark methods. Secret methods. Stuff related to multi threading