Dismiss Notice
You are browsing this site as a guest. It takes 2 minutes to CREATE AN ACCOUNT and less than 1 minute to LOGIN

Wanaojua java

Discussion in 'Tech, Gadgets & Science Forum' started by The hammer, Jul 4, 2012.

  1. The hammer

    The hammer JF-Expert Member

    #1
    Jul 4, 2012
    Joined: May 17, 2011
    Messages: 2,127
    Likes Received: 925
    Trophy Points: 280
    Maprogrammer nawezaje kutumia printf kwenye java mana kwenye vitabu wanaitumia sana ila kila nikijaribu inaniletea error,kuna nini kinachoweza kuleta error wakati code ipo vyema kwa kila kitu
     
  2. salito

    salito JF-Expert Member

    #2
    Jul 4, 2012
    Joined: Dec 29, 2011
    Messages: 1,090
    Likes Received: 3
    Trophy Points: 135
    hebu iweke hiyo line ya code inayoleta error
     
  3. Abdulhalim

    Abdulhalim JF-Expert Member

    #3
    Jul 4, 2012
    Joined: Jul 20, 2007
    Messages: 16,463
    Likes Received: 16
    Trophy Points: 135
    tuwekee hiyo code tuione basi
     
  4. The hammer

    The hammer JF-Expert Member

    #4
    Jul 4, 2012
    Joined: May 17, 2011
    Messages: 2,127
    Likes Received: 925
    Trophy Points: 280
    mfano
    System.out.printf("Welcome to java progrmming language\n%s!\n"getCourseName);
    Hapo error inakuwa kwenye f.
    NOTE:

    Then hata nikitumia statement ifuatayo inasumbua:

    final int ARRAY_LENGTH=10;
    int counter;
    int array[]=new int[ARRAY_LENGTH];
    for(counter=0; counter<array.length; counter++);
    array[counter]=2+2*counter;
    System.out.println("Index\tValue");
    for(counter=0; counter<array.length; counter++);
    System.out.println(counter);
    Tatizo linakuwa kwny array.length...............WHY
     
  5. babuwaloliondo

    babuwaloliondo JF-Expert Member

    #5
    Jul 4, 2012
    Joined: Mar 14, 2011
    Messages: 378
    Likes Received: 2
    Trophy Points: 0
    public class Sample
    {
    public Sample(){}


    public static void main(String []args)
    {
    final int ARRAY_LENGTH=10;
    int counter;
    int array[]=new int[ARRAY_LENGTH];
    for(counter=0; counter<array.length; counter++)
    array[counter]=2+2*counter;
    System.out.println("Index\t Value");
    for(counter=0; counter<array.length; counter++)
    System.out.println(counter +"\t"+array[counter]);
    }
    }

    Output
    Index Value
    0 2
    1 4
    2 6
    3 8
    4 10
    5 12
    6 14
    7 16
    8 18
    9 20

    ondoa semicolons kwenye for loops
     
  6. The hammer

    The hammer JF-Expert Member

    #6
    Jul 4, 2012
    Joined: May 17, 2011
    Messages: 2,127
    Likes Received: 925
    Trophy Points: 280
    Hiyo nimeiweka kimakosa tu,ila niliyoi-type kwenye comodo ipo sahihi,then iliyoirekebisha error inatokea kwenye

    array.length............au jdk ninayotumia siyo

    kwnn nikitumia hiyo printf na array.length inanikatalia...ni tatizo nimehangaika nalo mwezi sasa
     
  7. babuwaloliondo

    babuwaloliondo JF-Expert Member

    #7
    Jul 4, 2012
    Joined: Mar 14, 2011
    Messages: 378
    Likes Received: 2
    Trophy Points: 0
    for(counter=0; counter<array.length; counter++);// presence of semicolon at the end of for loop: syntax error
    array[counter]=2+2*counter;
    System.out.println("Index\tVal ue");
    for(counter=0; counter<array.length; counter++); // presence of semicolon at the end of for loop: syntax error
    System.out.println(counter);//replace with this System.out.println(counter +"\t"+array[counter]);
     
  8. H

    Hadoop Member

    #8
    Jul 4, 2012
    Joined: Oct 28, 2011
    Messages: 89
    Likes Received: 0
    Trophy Points: 0
    Ndugu sidhani kama kuna tatizo kwenye array.length. Weka code au segment yenye printf() tuone cause ya tatizo.

    Weka comma before variable or method name unazo call kwenye printf() statement.

    e.g: System.out.printf("Welcome to java progrmming language\n%s!\n" , getCourseName) ;


    Pia hiyo getCourseName ni method au variable? kama ni method nadhani inapaswa iwe getCourseName().
     
  9. A

    Aswel Senior Member

    #9
    Jul 4, 2012
    Joined: May 1, 2012
    Messages: 113
    Likes Received: 0
    Trophy Points: 33
    Hii iko poa nimeijaribu inarun fresh, labda kama unatatizo jingine.
     
  10. Kang

    Kang JF-Expert Member

    #10
    Jul 4, 2012
    Joined: Jun 24, 2008
    Messages: 4,698
    Likes Received: 203
    Trophy Points: 160
    error gani?? Tupe habari kamili usaidiwe.

    Nadhani hiyo method hauiiti sawa ni getName() sio getName kama ni method isiyo na parameters, pamoja na makosa waliyotaja wengine.
     
  11. S

    Striker Searcher Member

    #11
    Jul 4, 2012
    Joined: Jul 3, 2012
    Messages: 34
    Likes Received: 0
    Trophy Points: 13
    Nilikuwa najaribu kufuatilia syntax yako uliyotumia regarding to java recommended syntax. I've never ever come across pprintf() in java except in Cprogramming language. Ngoja nifuatilie then I'll back to you.
     
  12. SaidAlly

    SaidAlly JF-Expert Member

    #12
    Jul 4, 2012
    Joined: Jan 22, 2011
    Messages: 1,593
    Likes Received: 323
    Trophy Points: 180
    Duh! Bonge la giza, sijui nimepita huku kufanya nini.
     
  13. Mr.mzumbe

    Mr.mzumbe JF-Expert Member

    #13
    Jul 4, 2012
    Joined: Oct 11, 2011
    Messages: 745
    Likes Received: 8
    Trophy Points: 35
    wakuu kama kutakuwa na uwezekano ebu nitafutieni product ya even number kwenye code
     
  14. t

    teac kapex Senior Member

    #14
    Jul 4, 2012
    Joined: Jan 23, 2011
    Messages: 147
    Likes Received: 1
    Trophy Points: 35
    hata mimi sawa na kipofu sielewi hawa jamaa wanazungumzia nini
     
  15. Chimunguru

    Chimunguru JF-Expert Member

    #15
    Jul 4, 2012
    Joined: May 3, 2009
    Messages: 9,816
    Likes Received: 177
    Trophy Points: 160
    DAh nilizipiga sana hizi code enzi zangu siku hizi nimekuwa mvivu sana
     
  16. BHULULU

    BHULULU JF-Expert Member

    #16
    Jul 16, 2012
    Joined: Jun 28, 2012
    Messages: 4,880
    Likes Received: 64
    Trophy Points: 145
    Mkuu umenichekesha sana,mambo ya programming hayo!
     
Loading...