Hello world

This is my first draft!. “Hello world” is published by TK.

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Get to Know Loop Commands in Kotlin

As we know there were many of Loop Commands in another programming Language. And here today i wanna tell you guys how to use the Loop Commands using Kotlin Language.

So in the Kotlin Language, you have 3 loop commands that you can use. There are : For, While, & do-While.

For the First, i wanna show you how to use the Loop Command using “For”.

The For command actually used for sequential repetition. For example : a to z, 1 to 9, etc. Here’s some more example using the syntax.

In this context i was using the ‘A’ to ‘J’ for an example. you can also use numbers for the looping command using For.

Now the difference between two in the top is using the Char type value you must use the ‘ ’ on the character. but the Int type value didn’t need the ‘ ’ because it’s the different type value.

But we’re not stopped there yet. By using the For command you can use value in a keyword variable to count how many loop you will use to the value. Here’s the example :

By using it like this you can loop the value as much the value content. Then why in the example the word “adam ” repeated 5 times not 4 times? that is because in the word “adam ” i add one space in the value. So the space that was in the value is counted as one content. so that’s why the word “adam ” repeated 5 times.

Next up we’re heading to another loop command “While”.

The While command actually used for the same repetition. For Example : repeat the word “adam” 9 times. Here’s the example using the syntax.

While function is used to qualify data in the value. As long the data is still qualify to the while function, the function will still running until the data is not qualify to the while function. Remember that function will always count the first data index from zero.

But the while function is will still work as the for function. for example :

In exception that the character is can be repeated sequentially.

Next up we’re heading to another loop command “Do-While”.

Different with while command that will check the code first and then run the code, the do-while command will run the code first then check the qualify data. So that means whatever the data is qualify or not, the command will run code first, then check the qualify. Here’s the example using the syntax.

So as you can see, the while command doesn’t qualify the value of “ i ”. but however using the do-while command allow you to run the code first so that the value of “ i ” still printed even the value wasn’t qualify to the while command.

Maybe that’s it from me, today we’ve learned the looping command for the Kotlin Language, may this article helpful to you and thank you.

Inspired by : Salim Maula Hudzaifah

Add a comment

Related posts:

Work Affinity Notes

I would like the application to allow me to easily and quickly log my grades.. “Work Affinity Notes” is published by Stephen Manley.

Delete your student debt and stay one step ahead with Blockstack

2019 kicked off with over $1.5 trillion in U.S. student loan debt which is spread among 45 million borrowers. That’s about 50% more than the total U.S. credit card debt. Blockstack, the company…

Here are a few things to keep in mind when renting a car

Renting a car can help you save money on your travels. You can avoid unpredictable public transport schedules by renting a vehicle. Your daughter’s 23-year-old age and perfect driving record will not…