Modern Java - Top Features of Java 9 to 17

  Рет қаралды 89,756

Kamil Brzezinski

Kamil Brzezinski

Күн бұрын

In this episode we're going through the most interesting features added to the language in the last few years - between Java 9 released in 2017 and Java 17 released in September 2021.
00:00 Enhanced Switch
03:11 New instanceof
05:13 Type Inference (var)
06:50 Records
10:13 Text Blocks
11:32 Sealed Classes
16:06 of for Collections
17:16 Meaningful NullPointerException
Watch the next video about Java Stream API: • Java Stream API

Пікірлер: 159
@kamilbrzezinski8218
@kamilbrzezinski8218 Жыл бұрын
Watch the next video about Java Stream API: kzbin.info/www/bejne/q2qqgZuIn6eJsLc
@jmwild1
@jmwild1 2 жыл бұрын
Great summary. I decided to jump from 8 to 17 and this is a great highlight reel of features I am happy to see (except maybe "var"). Another feature I love now is how easy it is to read and write text files using Files.readString() and Files.writeString().
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
You're right, I should have covered it as well! Working with files in Java used to be a nightmare :)
@leonardoamorimramos5656
@leonardoamorimramos5656 2 жыл бұрын
Great content Kamil! I really appreciate your highlights. Thank you!
@SatheeshManimekalai
@SatheeshManimekalai 2 жыл бұрын
Clarity in your content is really appreciable. You saved my day and thanks a bunch.
@francksgenlecroyant
@francksgenlecroyant 2 жыл бұрын
Another man is subscribing to this channel! It's pretty awesome! Thank you for sharing!
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
Thanks! I've been running a programming channel in Polish for more than three years and people like it, so I hope to give similar value to an English-speaking audience now. I'm glad that you subscribed, new videos are coming soon!
@vladimirljubopytnov5193
@vladimirljubopytnov5193 2 жыл бұрын
You ignore the most important feature, of the switch... it can be an expression and you can return a value. Why repeat the System.out.println() 4 times, when you can simply return the club and print it using one println call? Everyone seems to be obsessed about doing their side effects everywhere... Method is easier to test when you return a value.
@fltfathin
@fltfathin 2 жыл бұрын
am JS pleb here, just to be clear does it work like this? T fn (args) { return switch(value){...}} ?
@Kartoflaszman
@Kartoflaszman 2 жыл бұрын
@@fltfathin yes, exactly. Expressions can be returned but statements (like if) cannot.
@johndoedoejohn
@johndoedoejohn 8 ай бұрын
But this is for education purpose. System out is returning something as well, just to console, so it's still returns something 😄
@vladimirljubopytnov5193
@vladimirljubopytnov5193 8 ай бұрын
@@johndoedoejohn System.out.println has a return type of void, that means it does not return anything. Side effect is not a return value.
@DDVrns
@DDVrns 2 жыл бұрын
Great video! We need more Java videos like this, very easy to digest and helps with interviews for example (Just had a couple of interviews with new feature questions). Subbed and hoping to see more. Keep it up!
@kamilbrzezinski8218
@kamilbrzezinski8218 Жыл бұрын
Hi Daniel! It took me a while but I've just published a new video about Stream API: kzbin.info/www/bejne/q2qqgZuIn6eJsLc
@pranavmahajan4190
@pranavmahajan4190 Жыл бұрын
Recently switched to Jave 17. This is a great video. Thanks so much
@kamilbrzezinski8218
@kamilbrzezinski8218 Жыл бұрын
Thank you! I'm planning to make a video about Java 21 soon, there are some really interesting changes coming up! Yesterday I published a new video about Stream API: kzbin.info/www/bejne/q2qqgZuIn6eJsLc And I'm planning to publish new videos more often now:)
@gennadiisitnikov1234
@gennadiisitnikov1234 Жыл бұрын
Great! Simple explanation and demonstrative examples. Thanks a lot!
@CaseStudy-bx4tl
@CaseStudy-bx4tl Жыл бұрын
Very Helpful video for revising the concept in a short time thanks man!!
@yamibakura7491
@yamibakura7491 2 жыл бұрын
Clear & concise, thankyou for making this video
@ybendek
@ybendek 2 жыл бұрын
wow man, awesome summary... I'm starting a new migration for a big project from java7... and now I need to know more about new features...thanks ;)
@tanmayshukla4593
@tanmayshukla4593 2 жыл бұрын
That was really amazing man! You earned a like and subscribe!
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
Thank you!
@trannam4195
@trannam4195 2 жыл бұрын
Very imformative video. Thank you so much!
@DrFrancis1686
@DrFrancis1686 Жыл бұрын
Awesome video, thanks a lot!
@rohitgupta025
@rohitgupta025 2 жыл бұрын
Thank you for simple and easy presentation
@ayushgupta8239
@ayushgupta8239 2 жыл бұрын
Awesome content!! Sealed class concept is really interesting.
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
It really is! I also recommend Venkat Subramaniam's talk on Sealed Classes: kzbin.info/www/bejne/jpzLZqaXaNudiqc
@VaibhavPatil-rx7pc
@VaibhavPatil-rx7pc 2 жыл бұрын
Excellently delivered
@danieldias224
@danieldias224 2 жыл бұрын
Great video! I recently saw a meme praising Java 19 (I think), and was surprised to see what the fuss was all about. Not surprised to know that most of these features are already built in Kotlin.
@eric-wubbolameijer9558
@eric-wubbolameijer9558 2 жыл бұрын
As a concrete example where var is very handy: Spring! ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); Saves copy-pasting (or worse, retyping) the class name!
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
And it makes the code much easier to read! Variable names are much more important than the class names and such long names like ClassPathXmlApplicationContext are nothing but noise.
@mohamedsulaimaansheriff9787
@mohamedsulaimaansheriff9787 2 жыл бұрын
Great video! Subscribed❤❤
@parkerbelholland1037
@parkerbelholland1037 2 жыл бұрын
Thanks and good comments too. Been using Java for years and haven't had the courage to jump from 8 yet. Still have nightmares jumping from 3 to 4 or 5.
@faisalbehram7125
@faisalbehram7125 2 жыл бұрын
Appreciated... Learn alot from this video thank you
@haajiraaliyar78
@haajiraaliyar78 Жыл бұрын
Useful Information on java 17.!!Excellent.
@VibhuthaKumarage
@VibhuthaKumarage 2 жыл бұрын
Very useful video. Thanks!
@chethan93
@chethan93 2 жыл бұрын
Awesome primer🤘🏽
2 жыл бұрын
Great video, thanks!
@widearchshark3981
@widearchshark3981 Жыл бұрын
This is such a great video. Haven't touched Java in years, and wanted to see what the differences were... Perfect ! Loving that NullPointerException message now. You know what it's like. As hard as you try, something somewhere doesn't get set. Then you're spending ages figuring out the specifics. This just gives you that little bit more detail to get you started. Really don't get the point of sealed classes/interfaces though. One useful thing I guess is it tells you which classes implement/extend it. But still, could come back to bite you in the ass I reckon! Thank you anyway. Really useful.
@kamilbrzezinski8218
@kamilbrzezinski8218 Жыл бұрын
I don't like the concept of sealed classes either. Venkat Subramaniam made an interesting video about it kzbin.info/www/bejne/jpzLZqaXaNudiqc, but still I just don't see myself using this feature in any future projects.
@bronzekoala9141
@bronzekoala9141 9 ай бұрын
I love them, but I actually can't believe it took so long (C# too) to get them. It's such an obvious improvement and, from an outsiders perspective, low hanging fruit for improved efficiency when developing.
@bronzekoala9141
@bronzekoala9141 9 ай бұрын
@@kamilbrzezinski8218 I don't like it as a concept either, but I read it improves performance because the compiler knows when and where to look for inheriting classes.
@skagro1995
@skagro1995 2 жыл бұрын
Good video, you should add that records are inmutable , perfect for functional programming
@svalyavasvalyava9867
@svalyavasvalyava9867 Жыл бұрын
great video, thank you!!!
@didimoner
@didimoner 2 жыл бұрын
Helpful video, thank you!
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
Thanks Dmitry!
@nakulkumar9415
@nakulkumar9415 2 жыл бұрын
Great video. I guess you forgot to mention that when creating collections using of method the collections created are immutable. Also for set there must be no duplicates.
@temrimoose
@temrimoose 2 ай бұрын
Great job bro , thanks from morocco ❤
@gregmcpherson5671
@gregmcpherson5671 2 жыл бұрын
Thanks! I'll use a good deal of what you showed there. My Java writing is still shamefully very Java 8.
@fc6827
@fc6827 2 жыл бұрын
I appreciate the summary. While nothing quite as ground breaking as generics or function programming introduced in 7 and 8 (I think generics were 7?), really nice features if I can remember to use them!!
@jibranjaved6165
@jibranjaved6165 2 жыл бұрын
Java 5
@nopalfi1409
@nopalfi1409 2 жыл бұрын
Great summary, i was kinda wonder about this because i started to learn java in JDK 17, but a few years ago i bought a book about java but it was 1.8 so i kinda wonder what feature i missed 😄
@sheebaashraf
@sheebaashraf 2 жыл бұрын
Thanks a lot v quick and informative
@vincentmax4571
@vincentmax4571 Жыл бұрын
Very good information.
@MrBrackets
@MrBrackets 10 ай бұрын
great video, thnks for sharing!
@InderjeetSingh007
@InderjeetSingh007 Жыл бұрын
Superb!
@user-mc5xb3hc7m
@user-mc5xb3hc7m Жыл бұрын
excellent summary
@ashutosh887_
@ashutosh887_ Жыл бұрын
Amazing Dude
@user-qb3ck7cq3k
@user-qb3ck7cq3k 10 ай бұрын
Thank you!
@rahulgoti3864
@rahulgoti3864 7 ай бұрын
Amazing Video :)
@The_Original_Homeboy
@The_Original_Homeboy Жыл бұрын
Good stuff. My project is currently stuck on Java 8 so it's interesting to see what changes have been made to the language.
@kamilbrzezinski8218
@kamilbrzezinski8218 Жыл бұрын
It's almost like a new language! :) And in September there will be Java 21 which also brings a lot of new features. I'm going to make a video about them soon! Now I only covered a new approach to the main method: kzbin.info/www/bejne/poWvl6qeeLSeh9U
@shantilalprajapat4924
@shantilalprajapat4924 2 жыл бұрын
Loved it 😍😍
@ionthefightingaxe3835
@ionthefightingaxe3835 2 жыл бұрын
Simple and informative👍
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
Good to hear, thanks!
@MrAikien
@MrAikien Жыл бұрын
Thanks! 👌👍
@jaskiratbamrah13
@jaskiratbamrah13 2 жыл бұрын
I just save it in my GYM category , I will watch it later. I know this will help for sure.
@obvioustruth
@obvioustruth 2 жыл бұрын
Cześć Kamil!!! Pamietam Cię z FTIMS na Polibudzie Łódzkiej z 2013r :)
@neilclay5835
@neilclay5835 Жыл бұрын
useful summary thanks
@adyanto4043
@adyanto4043 2 жыл бұрын
Null Pointer exception is the best frenemy of java.
@amizan8653
@amizan8653 2 жыл бұрын
Super good video, thank you for posting! After seeing this... man I wish my company would adopt java 17 instead of continuing on with bloody Java 8.
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
This is the grim reality, but Java 8 is the Windows XP of programming world ; ) Sometimes it feels like it'll be used forever.
@challasaibhanuteja5314
@challasaibhanuteja5314 2 жыл бұрын
nice and informative
@abdelkaderkaouane9682
@abdelkaderkaouane9682 2 жыл бұрын
Thank you
@Kamil-mw9jw
@Kamil-mw9jw Жыл бұрын
Rapidly changing :D That was funny ;)
@chax0208
@chax0208 2 жыл бұрын
Im an apprentice that got taught by someone using Java 8. ur using 17 damn new features are good
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
They are! Too bad so few companies are really using new versions of Java.
@RonaldoArch
@RonaldoArch 8 ай бұрын
great!
@Unknown-hu4gf
@Unknown-hu4gf 2 жыл бұрын
Hey, how do I get IntellJ IDEA to now hang and stutter when using it? Do I need a bigger CPU or something? I'm using a SSD and 32GB of RAM and my cpu is just a two core AMD, but it has a 3.4Ghz rating. And the thing just won't run smoothly! Are their configuration settings that I'm not using or something?
@madhulikadubey
@madhulikadubey 2 жыл бұрын
Nice content
@g0thqu054
@g0thqu054 Жыл бұрын
Thnx a lot for this nice content ! I have one question regarding records, could I use them for entities in spring with the annotation @entity?
@kamilbrzezinski8218
@kamilbrzezinski8218 Жыл бұрын
It took me a while to answer:) It's possible in Sprig Boot 3: dzone.com/articles/how-to-best-use-java-records-as-dtos-in-spring-boo
@MrSdsc81
@MrSdsc81 4 ай бұрын
Great video. Would love to have all this features sorted by Java version 😂 but it is cool anyway
@Naglfar83
@Naglfar83 2 жыл бұрын
Good explanation! Thank you much! Even though I don't see "var" as a top feature, but merely as something I have to criticize in future code reviews. ;-)
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
One of the viewers came up with a concrete example where var can be used - long class names like ClassPathXmlApplicationContext. And I agree with this because usually a variable name is more important than a class name. So var is kind of a syntactic sugar making code a little bit cleaner and easier to read :) But I also agree that's not much and probably it'll be used extremely rarely ; )
@jack_papel
@jack_papel 2 жыл бұрын
When you have to initialize a List you'll remember this comment 😅
@02orochi
@02orochi 2 жыл бұрын
U know Types are not always that relevant, right?
@rishiraj2548
@rishiraj2548 Жыл бұрын
Danke
@vaishakhm3011
@vaishakhm3011 Жыл бұрын
Nice feature
@zshn
@zshn 2 жыл бұрын
Does Record support meaningful NPE?
@vorpal22
@vorpal22 Жыл бұрын
(Great video, though... as someone who largely migrated from Java 1.8 to Kotlin, it's good to see this information presented concisely instead of having to dig it up all over the place.)
@ananthakrishnankrishnan7287
@ananthakrishnankrishnan7287 Жыл бұрын
What’s the IntelliJ font you’re using?
@mansoormohamedali122
@mansoormohamedali122 2 жыл бұрын
Plz which editor or ide are using.
@ssswdon
@ssswdon 9 ай бұрын
There use to be a flag that would allow NPE to generate a stack trace. I think they introduced in java8 and short cycling of NPE
@Robin-od5cf
@Robin-od5cf Жыл бұрын
What theme are you using for your IDE here?
@kamilbrzezinski8218
@kamilbrzezinski8218 Жыл бұрын
It took me a while to answer, but it's Nord: www.nordtheme.com/
2 жыл бұрын
when should you use records vs classes?
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
When you want to have an immutable class that just holds data. It was present in Kotlin many years ago: kotlinlang.org/docs/data-classes.html And now Java introduced the same feature :)
@aashishpundir3019
@aashishpundir3019 Жыл бұрын
please let me know if someone finds a better explanation... I don't even think it exists.. Awesome explanation.
@kamilbrzezinski8218
@kamilbrzezinski8218 Жыл бұрын
Thank you! I'm glad you liked it.
@marcosdantasguimaraesfilho7747
@marcosdantasguimaraesfilho7747 Жыл бұрын
Amazing content! Such a shame you only have three videos out :(
@JakNauczycSieProgramowania
@JakNauczycSieProgramowania Жыл бұрын
Hi Marcos! I'm going to start working on this channel! The new video should be out this week!
@marcosdantasguimaraesfilho7747
@marcosdantasguimaraesfilho7747 Жыл бұрын
@@JakNauczycSieProgramowania Glad to hear that!
@kamilbrzezinski8218
@kamilbrzezinski8218 Жыл бұрын
@@marcosdantasguimaraesfilho7747 Hi Marcos! I've just published a new video: kzbin.info/www/bejne/q2qqgZuIn6eJsLc
@Typelolpro
@Typelolpro 2 жыл бұрын
what is the color scheme/theme you are using?
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
It's Nord: www.nordtheme.com/
@bb5242
@bb5242 2 жыл бұрын
Groovy had the text blocks and var (def) at its inception, like in 2009 or whatever.
@elgs1980
@elgs1980 2 жыл бұрын
You forgot to mention if Record covers hashCode, equals and toString or not? If not, there is little difference between using a class with all public fields.
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
It covers all of them. And Record is immutable, so instead of writing/generating this (or using Lombok): public class Person { private final String name; private final String address; public Person(String name, String address) { this.name = name; this.address = address; } @Override public int hashCode() { return Objects.hash(name, address); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof Person)) { return false; } else { Person other = (Person) obj; return Objects.equals(name, other.name) && Objects.equals(address, other.address); } } @Override public String toString() { return "Person [name=" + name + ", address=" + address + "]"; } public String getName() { return name; } public String getAddress() { return address; } } you only need to write this: public record Person (String name, String address) {}
@alessioantinoro5713
@alessioantinoro5713 Жыл бұрын
If I remember well, the record toString(), equal() have a deafault implementation, so you are not forced to implement them
@thibaulturien9103
@thibaulturien9103 2 жыл бұрын
Wow great! If oracle keep this pace, by java 25 they will provide the same features as scala 2 with meaningful NPE on top of it! 😃
@katarzynabrzezinska8546
@katarzynabrzezinska8546 2 жыл бұрын
👍👍👍
@morebowmore
@morebowmore 2 жыл бұрын
15:29 This feature violates OCP. Does Java really need it?
@4L0N3xD
@4L0N3xD 2 жыл бұрын
5:14 so just like that all "adventages" of Python went away
@CallidusLynx
@CallidusLynx 2 жыл бұрын
Nice presentation... new features have a little Kotlin touch, don't they?
@somakkamos
@somakkamos Жыл бұрын
And yet java refuses to introduce tuples ... as are present in python.. its such a handy construct.. i guess record would be a way to achieve it..bt still u wud require a verbose atleast 1 liner to achieve it But awesome video... loved the depth yet simplicity
@AB-ms7my
@AB-ms7my 2 жыл бұрын
5:44 typo. Should be "name3"
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
You're right, thanks for catching this! It wouldn't have changed the behaviour though - if we use 'var' we need to initialize a variable in the same line.
@kalyanchakravaty8445
@kalyanchakravaty8445 2 жыл бұрын
realtime projects please
@rolfschierkowski8869
@rolfschierkowski8869 2 жыл бұрын
You can also use umlauts in Java. So it's Müller not Muller.
@JakNauczycSieProgramowania
@JakNauczycSieProgramowania Жыл бұрын
Yes, but since I don't use the German keyboard, I would need to manually copy the character from the Unicode table:)
@imMavenGuy
@imMavenGuy 11 ай бұрын
That's what she said - 8:23 😅
@kamertonaudiophileplayer847
@kamertonaudiophileplayer847 2 жыл бұрын
But how to fall throw? You give also lot of examples using audio files. Maybe you know that Java can directly to stream music to DAC now? Just kidding, I know it can't.
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
But why would you like to fall through? For me it always seemed like a bad design.
@kamertonaudiophileplayer847
@kamertonaudiophileplayer847 2 жыл бұрын
@@kamilbrzezinski8218 Some time both cases are the same except a line of the code. So I do something like : case1, cases2: if case1 then doSomeSpecific(); doCommon(); How should it look when a good design?
@LittleLily_
@LittleLily_ 2 жыл бұрын
@@kamertonaudiophileplayer847 Just move doCommon(); to after the switch. If you need the common to run for multiple cases but not all then you probably need to refactor something since at that point you're trying to be too clever for your own good and it'll just lead to confusing code.
@kamertonaudiophileplayer847
@kamertonaudiophileplayer847 2 жыл бұрын
@@LittleLily_ If a language gives some feature, you always try to use it. Otherwise, it sounds fishy, the language contains some features in state - do not use them. Maybe it is time to select a different language?
@friedec3622
@friedec3622 9 ай бұрын
Say it with me, "public static void main (String[] args)"
@typingcat
@typingcat 2 жыл бұрын
For an old language like Java, trying to implement modern features without breaking the old code's compilability (it's a word, right?) does not seem to result in a good syntax. Why not just add some sort of compiler directive at the beginning of a file? So, if there is nothing, then compile it like Java 6 or something. If the file has something like /***Java 17*/ at the beginning, then compile it with a new syntax. This way, the Java language designers would have much more freedom to revive this relic language of the 1990's.
@vladimirljubopytnov5193
@vladimirljubopytnov5193 2 жыл бұрын
New syntax for JVM is usually signaled using a different extension like .kt or .sc (and different compiler is needed :D)
@marcmil4064
@marcmil4064 2 жыл бұрын
People sometimes copy and paste code snippets, making it easy to create incompatible code in the process if there was such a compiler directive and backwards incompatible syntactic changes.
@clement1370
@clement1370 Жыл бұрын
Where is Mbappé ? 😌
@kIllera911
@kIllera911 2 жыл бұрын
Hi Messi, Welcome to Manchester United
@yohaneskustiadi9807
@yohaneskustiadi9807 2 жыл бұрын
So java 17 essentially almost like kotlin
@JentaroYusong
@JentaroYusong 2 жыл бұрын
Mostly, just with a way more verbose syntax. 😂
@VuLinhAssassin
@VuLinhAssassin 2 жыл бұрын
Problem is: most of these new features won't be adopted by "big tech" companies anytime soon, because... I think those corporations are the biggest obstacles to the development of java, as they almost have the final say over the technologies they will use, and how they plan to "upgrade" the infrastructure to accomodate modern Java. No matter how Java improves, they can just choose other modern languages for their projects.
@unbekannter_Nutzer
@unbekannter_Nutzer 11 ай бұрын
@5:45 you like to show, that `var name3;` can't be used, because it needs initialization on declaration, but you're trying to show it by assigning to `name` instead of `name3`. ;)
@diegoramos27
@diegoramos27 2 жыл бұрын
I’ve been a Java developer for over 10 years but after the serious Logj4 vulnerability it makes me wonder if this still still the correct path…
@nathandunkley4749
@nathandunkley4749 2 жыл бұрын
Switch to Rust. That's the language of the future
@02orochi
@02orochi 2 жыл бұрын
Go for groovy, its still java but in an Arguably better language
@jimmykochi6442
@jimmykochi6442 2 жыл бұрын
Kotlin is also great, only jetbrains tooling available tho
@marcmil4064
@marcmil4064 2 жыл бұрын
@@jimmykochi6442 Kotlin code is essentially equivalent to Java code in terms of vulnerabilities.
@mayankmittal1344
@mayankmittal1344 Жыл бұрын
It would have been a better video if you gone through the changes in the chronological order.
@kamilbrzezinski8218
@kamilbrzezinski8218 Жыл бұрын
Might be a topic for another video :)
@guidow9616
@guidow9616 2 жыл бұрын
or just switch to Scala or Kotlin
@Videshideshbhakt
@Videshideshbhakt 2 жыл бұрын
Java seems to Kotlin now!
@kamilbrzezinski8218
@kamilbrzezinski8218 2 жыл бұрын
For sure they took a lot of inspiration from Kotlin and that's good!
@vorpal22
@vorpal22 Жыл бұрын
At 8:00, why are you inserting getters if the fields are declared final? What's the point? Just make the variables public. (Not to say that records aren't a huge improvement, like Kotlin data classes, but still... I'm not even sure why records can't make their variables public and need to add accessors.)
@egozMaster
@egozMaster Жыл бұрын
do you know OOP rules ?
@vorpal22
@vorpal22 Жыл бұрын
@@egozMaster Yes, I do, and I can see why you might want to make them methods if you decide to change their underlying representation at some point, but for something this simple, you will almost certainly not. Look at Java Swing (and other Java APIs, but Swing is where it is most prevalent from what I've seen), for example: it defines a huge number of final constants with int values (not enums) to be passed to things like borders, alignments, etc. Following strict OOP rules is so late 1990s / early 2000s. Most of the organizations I know and have worked with now use a combination of immutable objects (which are basically equivalent to records) and functional programming instead of long-winded pointless strict OOP principles. I mean, if you want to aim for verbosity and redundancy, knock yourself out, but a final field that stores a primitive type or an abstract interface is just as good as a getter. Do a basic google search and you'll see that pointless getters have fallen out of fashion. There's no need to aim for strict purity unless you're a pedant.
Java Stream API
27:43
Kamil Brzezinski
Рет қаралды 1,3 М.
Little girl's dream of a giant teddy bear is about to come true #shorts
00:32
Fabiosa Animated
Рет қаралды 4,1 МЛН
Scary Teacher 3D Nick Troll Squid Game in Brush Teeth White or Black Challenge #shorts
00:47
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 18 МЛН
마시멜로우로 체감되는 요즘 물가
00:20
진영민yeongmin
Рет қаралды 31 МЛН
Что нового в Java 17?
38:20
Уголок сельского джависта
Рет қаралды 3,3 М.
The Amazing Features of Modern Java  - Venkat Subramaniam
1:02:01
Developer Summit
Рет қаралды 27 М.
Generics: The most intimidating TypeScript feature
18:19
Matt Pocock
Рет қаралды 167 М.
Observer Pattern - Design Patterns (ep 2)
49:47
Christopher Okhravi
Рет қаралды 558 М.
The Java Memory Model - The Basics
23:41
Jakob Jenkov
Рет қаралды 122 М.
Multithreading in Java Explained in 10 Minutes
10:01
Coding with John
Рет қаралды 896 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 774 М.
# 222  Java 17 Features | Java 17 Features Tutorial | RedSysTech
13:56
Little girl's dream of a giant teddy bear is about to come true #shorts
00:32
Fabiosa Animated
Рет қаралды 4,1 МЛН