r/javaProgrammer • • Mar 05 '19

5 Important Tips to Become a Good Java Developer

Thumbnail
technotification.com
3 Upvotes

r/javaProgrammer • • Feb 24 '19

Binary Exponentiation Algorithm

Thumbnail solutionfactory.in
3 Upvotes

r/javaProgrammer • • Feb 12 '19

Oracle Java Card updated for IoT applications

Thumbnail
javaworld.com
3 Upvotes

r/javaProgrammer • • Feb 06 '19

Why Object is the Super Class of All Classes in Java

Thumbnail
solutionfactory.in
3 Upvotes

r/javaProgrammer • • Jan 20 '19

How to start learning Java

Thumbnail
geeksforgeeks.org
3 Upvotes

r/javaProgrammer • • Jan 20 '19

How to Implement GET and POST Requests With Java

Thumbnail
dzone.com
3 Upvotes

r/javaProgrammer • • Jan 20 '19

Data Types in Java

3 Upvotes

Data type defines the values that a variable can take, for example if a variable has int data type, it can only take integer values. In java we have two categories of data type: 1) Primitive data types 2) Non-primitive data types – Arrays and Strings are non-primitive data types, we will discuss them later in the coming tutorials. Here we will discuss primitive data types and literals in Java.

Java is a statically typed language. A language is statically typed, if the data type of a variable is known at compile time. This means that you must specify the type of the variable (Declare the variable) before you can use it.
In the last tutorial about Java Variables, we learned how to declare a variable, lets recall it:

int num;

So in order to use the variable num in our program, we must declare it first as shown above. It is a good programming practice to declare all the variables ( that you are going to use) in the beginning of the program.

Primitive data types

In Java, we have eight primitive data types: boolean, char, byte, short, int, long, float and double. Java developers included these data types to maintain the portability of java as the size of these primitive data types do not change from one operating system to another.

byte, short, int and long data types are used for storing whole numbers.

float and double are used for fractional numbers.

char is used for storing characters(letters).

boolean data type is used for variables that holds either true or false.

byte:

This can hold whole number between -128 and 127. Mostly used to save memory and when you are certain that the numbers would be in the limit specified by byte data type.
Default size of this data type: 1 byte.
Default value: 0
Example:

class JavaExample { public static void main(String[] args) { byte num; num = 113; System.out.println(num); } }

Output:

113

Try the same program by assigning value assigning 150 value to variable num, you would get type mismatch error because the value 150 is out of the range of byte data type. The range of byte as I mentioned above is -128 to 127.

short:

This is greater than byte in terms of size and less than integer. Its range is -32,768 to 32767.
Default size of this data type: 2 byte

short num = 45678;

int: Used when short is not large enough to hold the number, it has a wider range: -2,147,483,648 to 2,147,483,647
Default size: 4 byte
Default value: 0
Example:

class JavaExample { public static void main(String[] args) { short num; num = 150; System.out.println(num); } }

Output:

150

The byte data type couldn’t hold the value 150 but a short data type can because it has a wider range.

long:

Used when int is not large enough to hold the value, it has wider range than int data type, ranging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
size: 8 bytes
Default value: 0
Example:

class JavaExample { public static void main(String[] args) { long num = -12332252626L; System.out.println(num); } }

Output:

-12332252626

double: Sufficient for holding 15 decimal digits
size: 8 bytes
Example:

class JavaExample { public static void main(String[] args) { double num = -42937737.9d; System.out.println(num); } }

Output:

-4.29377379E7

float: Sufficient for holding 6 to 7 decimal digits
size: 4 bytes

class JavaExample { public static void main(String[] args) { float num = 19.98f; System.out.println(num); } }

Output:

19.98

boolean: holds either true of false.

class JavaExample { public static void main(String[] args) { boolean b = false; System.out.println(b); } }

Output:

false

char: holds characters.
size: 2 bytes

class JavaExample { public static void main(String[] args) { char ch = 'Z'; System.out.println(ch); } }

Output:

Z


r/javaProgrammer • • Jan 16 '19

Java Developers never RIP

Post image
3 Upvotes

r/javaProgrammer • • Nov 20 '18

Join Community now for Learning Java Together

Post image
3 Upvotes

r/javaProgrammer • • Oct 20 '20

Group Chatting Application using socket programming in java

Thumbnail
youtu.be
2 Upvotes

r/javaProgrammer • • Oct 14 '20

Hi! I'm relatively new to Java, coming from python. I've made my own pac-man game on python, and I'm trying to replicate the same thing on java. Can anyone recommend an easy to learn GUI module?

2 Upvotes

r/javaProgrammer • • Oct 10 '20

Java 10 new features | All JDK 10 new features at glance with examples

Thumbnail
youtube.com
2 Upvotes

r/javaProgrammer • • Oct 04 '20

java 11 new features | local variable types in lambda expression parameters

Thumbnail
youtube.com
2 Upvotes

r/javaProgrammer • • Oct 04 '20

Java 11 new features | run or execute java program without compilation

Thumbnail
youtube.com
2 Upvotes

r/javaProgrammer • • Jul 14 '20

Webinar: Productive Web Development in Java with IntelliJ IDEA, Spring Boot, and Vaadin

Thumbnail
blog.jetbrains.com
2 Upvotes

r/javaProgrammer • • Jun 14 '20

Breadth First Search (BFS) Pseudocode and Program in Java

Thumbnail
atechdaily.com
2 Upvotes

r/javaProgrammer • • May 31 '20

Depth First Search (DFS) Pseudocode and Program in Java

Thumbnail
atechdaily.com
2 Upvotes

r/javaProgrammer • • May 08 '20

Don't touch it

2 Upvotes

r/javaProgrammer • • May 03 '20

Need help with some CODE

2 Upvotes

I am coding a mini uni assignment and the project is in java GUI. I’ve stumbled a bit and need help regarding an issue. Could someone tell me how I can have the same variable in two or three classes. The variable is basically to calculate the total of something and there’s different frames.

Thanks for any help in advance


r/javaProgrammer • • Apr 22 '20

How secure is Java compared to other languages?

Thumbnail
javaworld.com
2 Upvotes

r/javaProgrammer • • Apr 16 '20

Download and Installation of JDK

Thumbnail
youtu.be
2 Upvotes

r/javaProgrammer • • Feb 06 '20

Im confused on what I'm doing wrong with my if statements, I keep getting the last ticker i post no matter what I put after running. Did i format it wrong?

Post image
2 Upvotes

r/javaProgrammer • • Jan 04 '20

Develop a Java Application with Kafka

Thumbnail
dzone.com
2 Upvotes

r/javaProgrammer • • Dec 12 '19

Don't ever put a non-Java LTS release into production

Thumbnail
theserverside.com
2 Upvotes

r/javaProgrammer • • Dec 11 '19

The most copied StackOverflow Java code snippet contains a bug

Thumbnail
zdnet.com
2 Upvotes