need help with printing an array

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 1193 Views - Last Post: 29 June 2013 - 08:05 AM Rate Topic: -----

#16 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6538
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: need help with printing an array

Posted 28 June 2013 - 04:29 PM

View Postjasmin21patel, on 28 June 2013 - 04:29 PM, said:

hey can u please explain to me by like fixing to my code


Still sounds like 'gimme the codez' - Or 'Write my homework for me'

15 posts before posting his lame attempt - and never has taken the effort to implement the suggestions given. Just asks the volunteers to fix it for him.

Possibly a language barrier issues with the OP not understanding the suggested help or their instructor. But we can't do every assignment when they either don't understand the professor, or don't bother to pay attention or make an effort.

That's the last I'm saying on it. (unsubscribing)
Was This Post Helpful? 0
  • +
  • -

#17 jasmin21patel   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 20
  • Joined: 19-November 09

Re: need help with printing an array

Posted 29 June 2013 - 06:12 AM

i want to print array of string in this way

A)monday
B)tuesday
C)wednesday

but i am only able to print this way

monday
tuesday
wednesday

i have no idea how to get correct result please make me good working suggestion
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Jasmin
 */
public class practice {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String [] a = {"monday","tuesday","wednesday"};
         for (int i = 0; i < a.length;i++){
         
			System.out.println (a[i]);
       
     }
        
    }
}


Was This Post Helpful? -1
  • +
  • -

#18 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3744
  • View blog
  • Posts: 17,121
  • Joined: 20-September 08

Re: need help with printing an array

Posted 29 June 2013 - 07:21 AM

Try

    public static void main(String[] args) {
        char choice = 'A';
        String[] a = { "monday", "tuesday", "wednesday" };

        for (int i = 0; i < a.length; i++) {
            System.out.printf("%c) %s%n", choice++, a[i]);
        }
    }


Was This Post Helpful? 0
  • +
  • -

#19 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: need help with printing an array

Posted 29 June 2013 - 08:05 AM

Please avoid duplicate posting. Duplicate threads merged.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2