#How to not get depressed while programming in Java?

1 messages · Page 1 of 1 (latest)

torn flare
#

:((((

wary pastureBOT
#

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

wary pastureBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

sinful ferry
visual kayak
#

Java specifically or programming in general?

torn flare
#

Java

#

i like programming

visual kayak
#

What language r u coming from

sinful ferry
cinder spruce
#

most likely ur doing something wrong. hard to tell what, without any info

visual kayak
#

Maybe he doesnt like how strongly typed Java is or something

#

Coming from python at least

torn flare
#

used to programming in python and c. just finished coding a web app using the spring boot framework. it‘s insanely annoying to use java.

sinful ferry
#

what do you not like ?

cinder spruce
#

i can only repeat myself. ur most likely just doing something wrong. but its hard to tell what like that

#

i enjoy writting spring web apps in java 🤷‍♂️

pearl dagger
#

Impossible

#

No answer possible

#

Reqs for java: depressions, lol

tropic shard
#

You should just keep using Python or C. Why bothering yourself with something you do not like?

torn flare
#

my teachher wants us to code in java

tropic shard
#

To be honest, suck it up or drop the class. A lot of people are doing just fine with Python and C.

warm sage
#

idk, i love java.

gaunt ivy
#

It's not that one hates a particular language, it's the lack of familiarity/tools that could annoy you in whatever that is you wish to achieve

#

If you're gonna be stuck with Java for a while might as well invest time in learning it

#

@torn flare

sinful ferry
sinful ferry
# torn flare why is ther `int` and `Integer`?

The type system in java is spitted in 2, there are primitives types, which are immutable, identity less, passed by value (and so can't be null), don't have methods, don't support inheritance, are way faster and lighter, etc. And reference types aka objects which have identity, can be mutable, are passed by reference (and so can be null), have methods, support inheritance, etc
Primitive types are boolean, byte, short, char, int, long, float, double
The rest is reference types
Since primitive types have a lot of limitations, java added their equivalent as reference type as wrappers over those primitive types :

class Integer {
  int value;
  ...
}

Those wrappers of primitive types are called "boxed types" and can be used in places where you can't use primitive types :
List<int> → this doesn't compile, because a generic can only be a reference type, so you instead need to use List<Integer>, this is the most used case where you need to use boxed types
Another existing case is if you want a nullable primitive : since primitive can't be null, you have to use a boxed type. Also note that you can use Optional too ie OptionalInt
Also note that to convert from one to another, it's very simple :

int i = boxedInt.intValue();
Integer boxedInt = Integer.valueOf(i);

It's those two methods
And more importantly, note that the conversion is actually seemingless : you do'nt need to call those methods :

int i = boxedInt;
Integer boxedInt = i;

And the list of boxed types are Boolean, Byte, Short, Character, Integer, Long, Float, Double

TL;DR
Use Integer when you need to use int as a generic ie List<Integer> or when you need a nullable int, otherwise use an int
And the conversion is seemingless :

int i = boxedInt;
Integer boxedInt = i;