Print Text / Output Somo 3
Katika somo lililopita kuwa tunaweza kutumia println() method ku output values au ku print text kwenye Java
Mfano
System.out.println("Hello World");
Unaweza kuwa na println() method kwa idadi unayo itaka wewe , zingatia tu kila method itaenda kuongeza mstari mwingine
Mfano
System.out.println("Habari Ulimwengu");
System.out.println("Mimi najifunza java");
System.out.println("Nai furahia sana");
Double quotes/ funga semi na fungua semi
Wakati ukiwa una deal na maneno ni lazima yawe ndani ya double quote. **""**
Na ikitokea ukasahau double quotes itaenda ku print error
Mfano
System.out.println(" Hii sentensi ipo sahihi");
System.out.println(" Hii sentensi sio sawa");
Print() method
Pia kuna print() method ambayo ni sawa na println() utofauti print() method yenyewe hata ukizitumia mbili kwa mfuatano moja mstari wa kwanza na ingine ila katika output haitengenezi mstari mwingine inaunganisha
Mfano
System.out.print("Habari");
System.out.print("Huu ni mstari ungine");
Majibu
Habari Huu ni mstari ungine
Wakati ingekuwa ni ili inge print mistari miwili
Yaan
Habari
Huu ni mstari ungine
Java Output Numbers
Vile vile unaweza kutumia println() method ku print namba.
Lakini sio kama maneno , katika ku print namba hatuweki kwenye funga semi na fungua semi ( double quotes)
Mfano
System.out.println(3);
System.out.println(358);
System.out.println(5000);
Pia unaweza fanya mahesabu ndani ya println() method
Mfano
System.out.println(3+3);
System.out.println(2*5);
...Mwisho wa Somo la Tatu ........
Wasiliana na mimi kwa namba 0682329852 moja kwa moja
Jifunze kwa vitendo tazama video hii
Jiunge Telegram group Kujifunza na mijadala kuhusu programming
0 Comments