r/learnprogramming • • Apr 05 '22

Name one programming/comp sci concept you never understood and if you understand it, try to explain it to them

Name a programming concept such as virtual functions, pointers, certain algorithms, etc that you always had a hard time understanding and why.

Someone else who reads yours and does understand it, try to explain it to them to help them learn

1.6k Upvotes

738 comments sorted by

View all comments

19

u/[deleted] Apr 05 '22

Casting and upcasting in Java :/

1

u/GxK1999 Apr 05 '22

Casting i.e.:

double a = 3.0;

int b = a; //throws error because float type cannot be assigned to an int, therefor you need to cast it.

int b = (int) a; //output: 3