You are on page 1of 2

Name: John Allen E.

Atutubo Teacher: Sir Kenneth Lawas


Section: 11STEM(E)-2 Subject: Computer Programming 1

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.

2. What is the difference between BufferedReader and Scanner?


- The main difference between the two that I remember is that BufferedReader can only read
strings while Scanner can read more primitive data types other than string like int and float.
BufferedReader is synchronized and faster, so it is great for reading strings more efficiently.
In contrast, Scanner is asynchronous and slower so it is said that even if it can read other data
types and easily reads input, it’s not recommended for projects that needs to be done fast.

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\

You might also like