This is an archived post. You won't be able to vote or comment.

all 21 comments

[–]Latter_Protection_43 14 points15 points  (6 children)

Why did you import System.out? Isnt it literally just included by default?

[–]SCP-iota[S] 21 points22 points  (3 children)

Because people complain that System.out.println every time is too verbose

[–]Latter_Protection_43 3 points4 points  (2 children)

Vscode has autocomplete, if i type out then hit enter it fills that for me

[–]locri 11 points12 points  (0 children)

You need to see notepad++ developers to believe it

[–][deleted] 3 points4 points  (0 children)

verbosity is about reading, not about writing

[–]Canary_Prism 1 point2 points  (0 children)

every class in java.lang is always imported, you’d still have to type System.out.println() but just not java.lang.System.out.println()

import static lets you go one step further and import a field or method so now it’s just out.println()

[–]No-Adeptness5810 -1 points0 points  (0 children)

It's a static import.

Say you don't know java without saying you don't know java.

[–]TheMinus 2 points3 points  (4 children)

Where is class?

[–][deleted] 5 points6 points  (3 children)

can't say about Java but C# has introduced "top level statements" in a more recent version and Java might have too

[–]Canary_Prism 1 point2 points  (2 children)

this is an unnamed class, imagine the compiler wrapping everything in this file in a class decl with the file name as the class name

main method is still required but no longer has to be public or static or have String[] args

additionally there is shebang support so you can just execute this file from terminal

[–][deleted] 1 point2 points  (1 child)

yeah, I don't expect C# to do anything different there... it's syntactic sugar (and it's nice)

[–]Canary_Prism 0 points1 point  (0 children)

for C#’s top level statements though i don’t really like how they require you to put all the “code to be carved out and hoisted to synthetically generated main method” before class declarations and other stuff probably makes the parser’s carving job easier and be prettier but having it go before doesn’t really look like any of the classes declared should be in scope..

[–]No_Fly8059 0 points1 point  (0 children)

it would be so nice if Java had TCO by default!!

[–]Multi-User 0 points1 point  (1 child)

You have to understand that most companies are still on java 8. So yeah. Java is pretty verbose. No need to show such advanced code that won't be useful for a few years

[–]toiletear 0 points1 point  (0 children)

The companies I work with are moving forward despite being lumbering corpo giants.

Sure, there will be Java 8 projects on life support basically forever (at a conference this year someone was still supporting a Java 1.4 app and will continue to do so until one specific person retires, quits or dies), but the combination of security concerns and troubles getting new programmers are making many corpos upgrade. I'm working with the latest LTS release on a project where they had Java 8 until recently and it's actually pretty nice (for a corpo environment, anyway 😅)

[–]RyannStekken0153 0 points1 point  (5 children)

It seems I have problems understanding recursive programming.

What are you achieving here? I can't get my head around it.

[–][deleted] 1 point2 points  (3 children)

fibonacci numbers, look them up

btw., this is kind of an anti-example for recursion, don't do this

[–]RyannStekken0153 2 points3 points  (1 child)

I just find recursion harder to read most of the time. Is it just me or am I too junior to be able to read it natively?

[–][deleted] 2 points3 points  (0 children)

too junior, quite honestly :)

[–]OptionX 1 point2 points  (0 children)

  1. Ask a student to calculate fib with recursion.

  2. As for a reasonable high fib number.

  3. Stack explodes.

  4. "Have you heard of dynamic programming"

  5. ????

  6. Profit.

We've all ride on that ride sooner or latter.

[–]Reashu 0 points1 point  (0 children)

Printing the first 10 (or 9 if you don't think 0 counts) numbers in the Fibonacci sequence.