#Data structures and learning

1 messages · Page 1 of 1 (latest)

jolly owl
#

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

grave wyvernBOT
#

<@&987246399047479336> please have a look, thanks.

deep vale
#

its good to know what they are

#

Also if you want to get a job, everyone will give you DSA coding interview

trim sundial
#

in germany that isnt that much of a thing compared to US or others

tribal rampart
#

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

jolly owl
brisk kettle
#

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)

jolly owl
#

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);

brisk kettle
#

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();

brisk kettle
#
int i = 5;
Clock clock = new Clock();

List<Object> anything = new ArrayList<>();
anything.add(i);
anything.add(clock);
jolly owl
brisk kettle
#

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()

jolly owl
#

Oh I was taught that every class extends it but it cannot be made

brisk kettle
#

just some java code someone wrote

sharp zephyr
#
Object o = new Object();
royal ether
#

There's reasons to have bare objects

#

Not a lot of good ones anymore, but def reasons

jolly owl
sharp zephyr
royal ether
#

For use as lock objects, gravestones, sentinels etc

#

Esp in generic collections you're going to find some