java - Repeat statement for infinite times using loop? -
i want print like:
for(int i=0;i<should infinite;i++) { data loading. sleep(100); data loading.. sleep(100); data loading... sleep(100); }
below code not working
package com.queen.a01_simple_request; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.view.view; import android.widget.button; import android.widget.textview; public class mainactivity extends appcompatactivity { textview textview; button button; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); textview = (textview) findviewbyid(r.id.textview); button = (button) findviewbyid(r.id.button); button.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { (; ; ) { try { textview.settext("downloading file"); thread.sleep(1000); textview.settext("downloading file."); thread.sleep(1000); textview.settext("downloading file.."); thread.sleep(1000); textview.settext("downloading file..."); thread.sleep(1000); } catch (interruptedexception e) { e.printstacktrace(); } } } }); }
}
now, should loop infinite. dots should change 1 after forever. dont want set value i<1000. want implement this.
the first 3 "parts" of basic statement optional:
for ( [forinit] ; [expression] ; [forupdate] ) statement
so, whilst looks strange, valid loop (that nothing, forever):
for (;;);
in case, omit expression
:
for (int = 0; ; i++) { ... }
Comments
Post a Comment