Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: I am trying on how to print values from an array all to show up on a dialog using a f

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I am trying on how to print values from an array all to show up on a dialog using a f

    I am trying on how to print values from an array all to show up on a dialog using a for loop. Can anybody help me with this?
    double[] dailyTemperatures;
    		  dailyTemperatures= new double[7];
    		  for (int d = 0; d<dailyTemperatures.length; d++)
    		  		{
    		  			String t;
    		  			t = JOptionPane.showInputDialog(null, "Enter daily temperature values:");
    		  			dailyTemperatures[d] = Double.parseDouble(t);
    		        }// end for loop
    		  for (int i =0; i <= 6; i++)

    i want to print all my values in just one dialog box. I would rather use a for loop but if you guys can not tell me another way it is okay


  2. #2
    Junior Member
    Join Date
    Dec 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I am trying on how to print values from an array all to show up on a dialog using

    Ok meaby that can help something...

    import javax.swing.*;
    public class StringLengthTableModel{
     
    	public static void main(String[] args){
    	double[] dailyTemperatures = new double[7];
    	String a="";
    	for (int d = 0; d<dailyTemperatures.length; d++)
    	  		{
    		  		int[] t = new int[dailyTemperatures.length];
    	  			t[d]=new Integer(JOptionPane.showInputDialog("Enter daily temperature values:")).intValue();
     
    	  			String m="The temperature "+ d+ "   -   ";
    	  			a=a+t[d]+" Measure \n  "+m;
    	  		}
    	  JOptionPane.showMessageDialog(null,a);
    	}
    }
    Last edited by helloworld922; March 22nd, 2010 at 07:46 PM. Reason: [code] tags please

Similar Threads

  1. Replies: 1
    Last Post: December 22nd, 2011, 09:55 AM
  2. Assgining values to array indexes
    By chronoz13 in forum Collections and Generics
    Replies: 3
    Last Post: December 28th, 2009, 11:09 PM
  3. How do i show all the values in one window(JOptionPane)??
    By Antonioj1015 in forum AWT / Java Swing
    Replies: 1
    Last Post: November 25th, 2009, 09:24 PM
  4. Substitution of Values in Array
    By nyeung in forum Collections and Generics
    Replies: 2
    Last Post: October 26th, 2009, 09:02 PM
  5. Having trouble insert/sorting array values w/ binary searching.
    By bh-chobo in forum Collections and Generics
    Replies: 4
    Last Post: October 8th, 2009, 03:38 AM