Sunday, 13 December 2015

Loop Kontrol Pada Java - Java Loop Control - Java NetBeans

Di dalam pemrograman Java kita mungkin perlu menjalankan blok kode beberapa kali. Umumnya statements dijalankan secara berurutan. Statement pertama dalam function akan dieksekusi pertama juga, diikuti yang kedua dan seterusnya.
Bahasa pemrograman Java menyediakan berbagai struktur kontrol memungkinkan utnuk jalur eksekusi yang lebih rumit.
Sebuah loop statement  memungkinkan kita untuk mengeksekusi statement atau sekelompok statements beberapa kali dan berikut ini adalah bentuk umum dari pernyataan loop di sebagian besar bahasa pemrograman: 

sumber : http://www.tutorialspoint.com
Bahasa pemrograman Java menyediakan beberapa jenis loop untuk menangani kebutuhan perulangan. Klik link berikut untuk memeriksa rincian :

Loop TypeDeskripsi
Mengulangi pernyataan atau sekelompok pernyataan sementara kondisi tertentu adalah benar. Ini tes kondisi sebelum mengeksekusi badan loop.
Mengeksekusi urutan laporan beberapa kali dan abbreviates kode yang mengelola variabel loop.
Seperti pernyataan sementara, kecuali bahwa hal itu akan menguji kondisi pada akhir badan loop

Loop Kontrol Statements :

Loop kontrol statements mengubah eksekusi dari urutan normal. Ketika eksekusi meninggalkan ruang lingkup, semua objects otomatis yang dibuat dalam lingkup tertsebut akan hancur.
Java mendukung pernyataan kontrol berikut. Klik link berikut untuk memeriksa rincian mereka.
Control StatementDeskripsi
Mengakhiri lingkaran atau saklar pernyataan dan transfer eksekusi ke pernyataan segera setelah loop atau switch.
Penyebab loop untuk melewatkan sisa tubuhnya dan segera menguji kembali kondisinya sebelum mengulangi.

Penyempurnaan loop pada Java

Java 5 memperkenalkan loop yang telah disempurnakan. Terutama digunakan untuk melintasi elements termasuk arrays.

Syntax :

Syntax ditingkatkan pada for loop 

for(declaration : expression)
{
   //Statements
}
  • Declaration: Blok variable baru dideklarasikan, merupakan tipe yang kompatibel dengan elemen dari array yang kita akses. Variable akan tersedia dalam for blok dan nilainya akan sama dengan elemen array saat ini.
  • Expression: Mengevaluasi array yang kita butuhkan pada loop bila telah melewati. Ekspresi dapat menjadi variable array atau metode panggilan yang mengembalikan sebuah array.

Contoh:

Buka NetBeans dan buatlah class baru bernama Test lalu tuliskan kode berikut
public class Test {

   public static void main(String args[]){
      int [] numbers = {10, 20, 30, 40, 50};

      for(int x : nomor ){
         System.out.print( x );
         System.out.print(",");
      }
      System.out.print("\n");
      String [] nama2 ={"Agus", "Joko", "Andi", "Lusi"};
      for( String nama : nama2 ) {
         System.out.print( nama );
         System.out.print(",");
      }
   }
}
Berikut adalah hasil dari kode diatas
10,20,30,40,50,
James,Larry,Tom,Lacy,
itulah loop kontrol pada java, terima kasih pada http://www.tutorialspoint.com sampai ketemu pada postingan selajutnya. Keep It Up Guys !!!

29 comments:

  1. perfect explanation about java loop control .its very useful.thanks for your valuable information.java training in chennai | java training in velachery

    ReplyDelete
  2. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

    DevOps Training in Bangalore

    ReplyDelete
  3. A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. I am learning a lot from you.
    Click here:
    angularjs training in btm
    Click here:
    angularjs training in rajajinagar
    Click here:
    angularjs training in marathahalli
    Click here:
    angularjs training in bangalore
    Click here:
    angularjs training in pune

    ReplyDelete
  4. Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.
    Blueprism training in Chennai

    Blueprism training in Bangalore

    Blueprism training in Pune

    Blueprism online training

    Blueprism training in tambaram

    ReplyDelete
  5. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    Devops Training in Chennai

    Devops Training in Bangalore

    Devops Training in pune

    ReplyDelete
  6. Read all the information that i've given in above article. It'll give u the whole idea about it.
    java training in chennai | java training in USA

    ReplyDelete
  7. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    Data Science training in Chennai | Data science training in bangalore
    Data science training in pune | Data science online training
    Data Science Interview questions and answers | Python training in Kalyan nagar

    ReplyDelete
  8. I am a regular reader of your blog and being students it is great to read that your responsibilities have not prevented you from continuing your study and other activities. Love

    angularjs Training in chennai
    angularjs-Training in pune

    angularjs-Training in chennai

    angularjs Training in chennai

    angularjs-Training in tambaram

    ReplyDelete
  9. Thanks For Sharing The Information The Information shared Is Very Valuable Please Keep Updating Us Time Just Went On reading The Article Aws Online Course Python Online Course Data Online Course Hadoop Online Course

    ReplyDelete
  10. I really like your blog. You make it interesting to read and entertaining at the same time. I cant wait to read more from you.

    informatica mdm online training

    apache spark online training

    angularjs online training

    devops online training

    aws online training

    ReplyDelete
  11. Nice post. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated posts…
    Microsoft Azure online training
    Selenium online training
    Java online training
    Python online training
    uipath online training

    ReplyDelete
  12. Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
    If you are looking for any python Related information please visit our website Python Training In Bangalore page!

    ReplyDelete
  13. Thanks for sharing the knowledge. So useful and practical for me. I learned something new. Very well written. It was so good to read and useful to improve knowledge. If you are looking for any Hadoop related information, check our hadoop training institute in bangalore web page. Thanks a lot.

    ReplyDelete
  14. This is a very knowledge and informative post.
    Thanks for sharing with us,
    We are again come on your website,
    Thanks and good day,
    Please visit our site,
    buylogo

    ReplyDelete
  15. Thanks Admin for sharing such a useful post, I hope it’s useful to many individuals for developing their skill to get good career. thanks
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete
  16. Very interesting blog. Many blogs I see these days do not really provide anything that attracts others, but believe me the way you interact is literally awesome. I will instantly grab your rss feed to stay informed of any updates you make and as well take the advantage to share some latest information about

    CREDIT CARD HACK SOFTWARE which many are not yet informed of, the recent technology.

    Thank so much for the great job.

    ReplyDelete

  17. Nice article and thanks for sharing with us. Its very informative



    Plots in PHARMA CITY

    ReplyDelete
  18. In the wake of perusing your article, I was astounded. I realize that you clarify it well overall. What's more, I trust that different perusers will likewise encounter how I feel in the wake of perusing your article.
    data scientist training and placement

    ReplyDelete
  19. I surely acquiring more difficulties from each surprisingly more little bit of it
    data scientist training and placement

    ReplyDelete
  20. In the wake of perusing your article, I was astounded. I realize that you clarify it well overall. What's more, I trust that different perusers will likewise encounter how I feel in the wake of perusing your article.
    data analytics courses in hyderabad

    ReplyDelete
  21. Informative blog and knowledgeable content. Thanks for sharing this awesome blog with us. If you want to learn data science then follow the below link.
    Data Science Course in Hyderabad

    ReplyDelete

luvne.com ayeey.com cicicookies.com mbepp.com kumpulanrumusnya.comnya.com tipscantiknya.com