Results 1 to 2 of 2
  1. #1
    swilliams236 is offline Member
    Join Date
    Nov 2011
    Rep Power

    Default Help getting Histogram chart example working

    I have a histogram chart that I was given as an example. As I understand it, it is supposed to be working code, however, I can't get it to successfully compile.

    I keep getting an error "operator <= cannot be applied to int,int[]"

    Can someone help me see what I am missing? Am I supposed to be passing data to it from a section of my code? I'm having an incredibly hard time with graphing even after reading the tutorials. I can draw pre-defined shapes such as lines, rectangles, etc. but I am struggling with this one.

    Your help is greatly appreciated.

    Java Code:
    import javax.swing.*;
    public class Histogram
     public static void main(String args[])
      int n[] = {19, 3, 20, 7, 13, 19, 3, 19,1};
      String output = "";
      output += "Element \tValue\tHistogram";
      for (int i = 0; i < n.length; i++)
       output += "\n" + i + "\t" + n + "\t";
       //prints the bar
       for (int j = 1; j <= n; j++)
        output += '*';
      JTextArea outputArea = new JTextArea(11, 30);
      JOptionPane.showMessageDialog(null , outputArea,
      "Histogram Class",

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

    Default Re: Help getting Histogram chart example working

    j <= n

    j is an int and n is an array. Can you explain to me how an int can be greater or less than an array?
    Last edited by Junky; 11-21-2011 at 06:24 AM.

Similar Threads

  1. Help with histogram
    By Conan in forum New To Java
    Replies: 5
    Last Post: 11-02-2011, 04:51 AM
  2. need help with name histogram
    By cachico12 in forum New To Java
    Replies: 1
    Last Post: 05-09-2011, 09:27 AM
  3. Replies: 0
    Last Post: 02-08-2011, 09:51 AM
  4. histogram
    By little_man in forum New To Java
    Replies: 4
    Last Post: 11-13-2010, 02:38 AM
  5. Demo bar chart and pie chart
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-24-2008, 12:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts