Learn something new everyday.
Image for post
Image for post

Hi guys! Welcome to another day of practicing Java with me. Like I said on the last post, I brought some practice questions of StringTokenizer, so if you miss the last posts check them out before!

[Question 1] Split the String “sample” with delimiters “#”, “/” and includes delimiters into tokens.

String sample = "A#whole/new#/World";

Image for post
Image for post

Hi guys! Today I’m going to talk more about the StringTokenizer and the while statement which is another loop. The first post about StringTokenizer is on below.

[while & hasMoreTokens()]

Last time I used countTokens() to count how many tokens are there in the StringTokenizer. There are different way to check if the StringTokenizer has tokens.


Image for post
Image for post

StringTokenizer — One of the Java util package that breaks a String into tokens.

Hi y’all! Today I’m going to show you how to use the StringTokenizer. It’s very similar with one of the String method split(), but you might find StringTokenizer more convenient to use.

[StringTokenizer]

Unlike the split() method, the StringTokenizer is a class, so you have to create it with the new operator.


Image for post
Image for post

Hey guys! I know I told you that I’m going to bring some practice questions today, but I think it’d be better If I show you some more of the methods that you can use on the ArrayList.

Checkout my last post before we go!

(1) add() method 2

If we use the add() method like the last time, it will add the index at the end of the ArrayList, for instance,


Image for post
Image for post

ArrayList — Re-sizable array that java.util package provides.

Hi y’all! Today we’re going to take a look at the ArrayList. You would remember arrays, there are one dimensional and two dimensional arrays.

Basically all of them(one, two dimensional arrays, ArrayList) have the same purpose, which is storing elements.

[ArrayList]

ArrayList can be slower than the arrays sometimes, but it’s undeniably easier than that. You don’t have to fix its size when you declare it, and when you remove one of the index, it reorganize the array by itself! I’ll show you an example.


Image for post
Image for post

Hi guys! Today we’re going to practice the String methods that we’ve seen on the last posts. So before we go it’d be better to check them first.

Question 1. Get the word ‘school’ from the sample String, and store it in the answer String.

String sample = "I'm going to school tomorrow.";
String answer = "";

The answer is on below!


Image for post
Image for post

Following from the last time, let’s see what kind of methods we can use on the String.

(1) trim()

This method removes the spaces in the beginning and the end of the String. It doesn’t need parameter.


Image for post
Image for post

Hi y’all! In one of my old post I was talking about three String methods charAt(), equals(), length().

Today I’ll talk about more of the String methods that we can use often. Let’s get this started then!

(1) startsWith()

This method returns true if the String starts with the parameter String, and returns false if it doesn’t.


Image for post
Image for post

Hi guys! Today we’re going to practice return value of method. We’re going to make a program that users can sign up followed by certain rules.


Image for post
Image for post

Hi y’all! Following from the last time we’re going to keep work on the method.

Last time we’ve seen how to declare and call the method, so today I’ll talk about how to analyze the method.

[Analyzing Method]

To analyze it, you have to check three important part of the method.
(1) What does this method do?
(2) Does this method have parameters?
(3) Does this method have return value?

Let’s see the example of it.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store