#How to not get depressed while programming in Java?
1 messages · Page 1 of 1 (latest)
<@&1004656351647117403> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
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.
what
Java specifically or programming in general?
What language r u coming from
what do you not like ?
most likely ur doing something wrong. hard to tell what, without any info
Maybe he doesnt like how strongly typed Java is or something
Coming from python at least
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.
why ?
what do you not like ?
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 🤷♂️
You should just keep using Python or C. Why bothering yourself with something you do not like?
my teachher wants us to code in java
To be honest, suck it up or drop the class. A lot of people are doing just fine with Python and C.
idk, i love java.
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
then explain what you do not like so we can maybe help you like the language better please
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;