Professional Documents
Culture Documents
Written Work 1:
1. Explain in your own words the functionality of every data type in Java.
- Based on the lesson and my understanding, each of these data types in Java have their own
uses and stores distinct inputs.
String is a data type used to stash phrases, sentences, paragraphs or any text, these texts are
enclosed with double quotes (“”).
Int, on the other hand, just like its name keeps integers, either positive or negative as long as
it is a whole number, meaning it is not suitable for those with decimal numbers or fractions.
This is where the type Float comes in, it is for storing numbers with decimal numbers,
however it can only recognize up to 6 decimals, the later decimals would be rounded off until
the decimal numbers are just 6.
Next, we have Char which is short for characters, as it implies, it keeps single letter or
character. Char is like a subset of String, words are made up of characters, thus String
consists of Chars. If double quotes are used around the statements in String, we use single
quote (‘ ‘) around the character we are storing.
Lastly, we have Boolean, its function is to store only two specific values; it can only possibly
be true and false. It helps in conditioning or tracking truth and false based on the other values
in the program.
Through other sources, I was able to learn more differences between the two. I discovered
that BufferedReader’s buffer size is 8kb while Scanner’s is 1kb. This means, we should use
BufferedReader for files with long or many strings while Scanner is for not so large files with
data types. Lastly, Scanner uses custom delimiter like nextLine() etc. based on the data type.
On the other hand, BufferedReader is usually accompanied and can only read and store
strings with readLine() method.
Source:
5 Difference between BufferedReader and Scanner class in Java? Example. (2022, January 22). Java67.
https://www.java67.com/2016/06/5-difference-between-bufferedreader-and-scanner-in-java.html
learnprograming byluckysir. (2020, May 11). Difference between BufferedReader and Scanner in java.
[Video]. YouTube.
https://www.youtube.com/watch?v=-6Mb10dwvSA\