Learn something new everyday.
Image for post
Image for post

Hi guys! So last time we made snake and snail shapes using by Two Dimensional Array. The link of the last session is on below.

And now let’s solve some more!

[Question] Use the code below, put the numbers like the sample and print it out on the console.

int[][] two = new int[5][5];

sample. Diagonal numbers

1   2   4   7   11
3 5 8 12 16
6 9 13 17 20
10 14 18 21 23
15 19 22 24 25

Image for post
Image for post

Hi guys! Following the last post, today we’re going to practice the Two Dimensional Array! There’s a link of the last session below.

It’s always better when you solve the questions by yourself!

[Question] Use the code below, put the numbers like the sample and print it out on the console.

int[][] two = new int[5][5];

Sample 1. Snake

25  24  23  22  21
16 17 18 19 20
15 14 13 12 11
6 7 8 9 10
5 4 3 2 1

So the numbers go like this,


Image for post
Image for post

Hi y’all! Welcome to another Java session with me, and today I’m going to talk about the Two Dimensional Array. This is not that different with the one dimensional array, only difference between them, is that the two dimensional array is just a array of the one dimensional array! So before we go, it’d be better if you check out my post about one dimensional array.

[Two Dimensional Array]

So to declare the two dimensional array is not that difficult. You can just put one more set of brackets in the one dimensional array declaration, like below.


Image for post
Image for post

Hi guys! I know last time I told you that I’m going to talk about the two dimensional array this time, but I thought it’d be better to know the concept of the whole increment/decrement operator first, before we go too far. So let’s get this started! And don’t forget to checkout my old post about the operators!

Like I said in my old post, there are unary operator, which look like a++ , a-- , ++a , --a . But last time I told you both a++ and ++a mean a=a+1 , also a--, --a mean a=a-1 . …


Image for post
Image for post

Hi guys! It’s another String method practice today! Don’t forget to checkout my last posts below.

You can only use length() , charAt() , equals() method just like the last practice. Let’s do this!

[Question 1] Find all the “can” in the String quote, and print it out, and print other letters into under bar “_” Like the sample below.

String quote = "Whether you think you can or can't, you're right.";**The sample of the result on the console**
______________________can____can_________________

It’s a very famous quote by Henry Ford, and that is true. Think you can do anything! Yay! The answer is on below.


Image for post
Image for post

Hi guys! It’s a practice session today so if you missed my last post, check the link below!

So like I said last time, we only can use the method charAt(), length(), equals() for today’s questions.

[Question 1] How many ‘i’s are in the String str?

String str = "Life is a long lesson in humility."

Let’s print the numbers of index that have ‘i’ as value too if you could. Here the ‘i’s data type is char, so you can compare them with the comparison operator == . The answer is right on below, but try to solve this by yourself!


Image for post
Image for post

Method — A block of code that performs specific task.

Hi guys! Welcome to another Java session with me. Today I’m going to talk about the methods that we can use on String in java. Let’s get this started!

[Method]

I’m going to talk about method deeply in the future session, so for now all we need to know is how it works. Method is a block of code that performs specific task, followed by parentheses() . In the parentheses, we can put parameter which is a passed information. Some method need parameter, but some don’t. …


Image for post
Image for post

Hello! Last time we made a lotto number generator, today let’s make an improved lotto program! If you missed the last post, checkout the link below.

[Question] Generate the winning lottery program by following rules.

  1. From 1 to 52, pick the random numbers 1000 times.
  2. pick 5 numbers that was picked the most.

I’ll give you a big hint here. This time let’s use the index as the number 1 to 52, and use the for statement pick the random numbers 1000 times and when every time the random number coming out then add 1 on the index that is same with the random number!


Image for post
Image for post

Hi y’all! Like I said last time, today let’s generate the lottery program. If you missed the first Array & Random Practice, the link is right on below!

[Question] Generate the lottery program by the following rules.

  1. Make an array to save 6 random numbers.
  2. Pick first 5 numbers from 1 to 52. There shouldn’t be same numbers.
  3. The last sixth one is the bonus number, pick it from 1 to 10.

Try to solve it by yourself, and the answer is on below!


Image for post
Image for post

Hi guys! Welcome to another java exercise with me! Today let’s practice some more on array. If you missed the basic array sesh, check out my old post below!

[Question 1] Count how many even numbers in the array below and print it out.

int[] a = {1, 2, 3, 4, 5, 6, 7};

I know it’s way easier to count the numbers with your brain, but imagine when there are more than thousand random numbers and you have to count the even numbers in those by your hands and eyes…Let’s build this program for that. The answer is on below, and you know the drill!

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