I did some investigating and it appears the issue is located in the DefaultTableModel. Specifically, in the getColumnClass method. When I use only 2 columns in the columnNames String array:  (String[] columnNames = {"Icon", "Filename"})    Everything works fine. But when I add a third column:  (String[] columnNames = {"Icon", "Filename", "Size"}):    I start getting the NullPointerException error.  What am I doing wrong?  package jtablefun;  import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import javax.swing.Icon; import javax.swing.JFrame; import javax.swing.JTable; import javax.swing.filechooser.FileSystemView; import javax.swing.table.DefaultTableModel;   public class JtableFun extends JFrame{  /**  * @param args the command line arguments  */ public static void main(String[] args) {     // TODO code application logic here    new JtableFun().show(); }  public JtableFun(){     getContentPane().setLayout(new GridBagLayout());      //String s[] = f.list();         buildTable();      pack();      addWindowListener(new WindowAdapter(){          public void windowClosing(WindowEvent e){             System.exit(0);         }      });  }    public void buildTable(){              File f = new File("/");              File[] fl = f.listFiles();               String fileNames[] = f.list();              Icon iconArray[] = new Icon[fileNames.length];             //Icon icon = FileSystemView.getFileSystemView().getSystemIcon(f);             for(int i=0; i&lt;fileNames.length; i++){                  iconArray[i] = FileSystemView.getFileSystemView().getSystemIcon(fl[i]);              }       String[] columnNames = {"Icon", "Filename", "Size"};       Object[][] data = new Object[fl.length][(fl.length * 2)];      for(int row=0; row&lt;fl.length; row++){           for(int column=0; column&lt;2; column++){              if(column == 0){              data[row][column]= iconArray[row];                      }else if(column == 1){                         data[row][column]= fileNames[row];                       }else if(column == 3){                         //data[row][column]= fl[row].length();                       }          }      }               DefaultTableModel model = new DefaultTableModel(data, columnNames)     {         //  Returning the Class of each column will allow different         //  renderers to be used based on Class         public Class getColumnClass(int column)         {             return getValueAt(0, column).getClass();         }      };                      JTable table = new JTable( model );                             table.setPreferredScrollableViewportSize(table.getPreferredSize());     GridBagConstraints g = new GridBagConstraints();     g.gridx =0;     g.gridy =0;     getContentPane().add(table,g); } }
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
How did Amix Group get this helicarrier? In Deadpool,       A big fight scene takes place in a battered helicarrier at an Amix Group scrap yard.     What is the history of this particular helicarrier? And why in particular was it sent to the Amix Group scrap yard? How do I install an older version of an app on an iPhone? How to prove $4(n!)>2^{n+2}$ for $ n\geq 4$ with induction I've done the base step, but how do I prove it is true for $n+1$ without using a fallacy? $$4(n!)&gt;2^{n+2}\quad \text{for } n\geq 4$$ Please help. How to remove desktop environments? I installed few environments that I wanted to try out on Ubuntu 12.04, but none of them worked at all. It could be that I installed them all at the same time, meaning the OS didn't get a chance to work everything out, but either way, they didn't work. I would now like to remove them.   The one's that I installed are Xubuntu/Xfce, Lubuntu/LXDE, Kubuntu/KDE, Fluxbox, OpenBox, cinnamon, and MATE. I installed them. Everything seemed to have been working properly until I actually tried to use the shells and nothing loaded at all. Except for Fluxbox, I think that one worked. I want to know of any way to repair or perhaps just remove the packages entirely. I might have already removed them because I did the apt-get remove command on all of them, but they were still in the list on the login screen. New global preferences: keyboard shortcuts and sticky topbar 'An avalanche of mail'? - it should be 'mails', shouldn't it? I came across this example on WordWeb while going through the meaning of the word ''.     the program brought an avalanche of mail (Just like "a group of man men").   I'm quite sure it should be mails. Kindly confirm. How can I change the master volume level? Using this code  [DllImport ("winmm.dll")] public static extern int waveOutSetVolume (IntPtr hwo, uint dwVolume);  waveOutSetVolume (IntPtr.Zero, (((uint)uint.MaxValue &amp; 0x0000ffff) | ((uint)uint.MaxValue &lt;&lt; 16)));   I can set the wave volume but if the master volume is too low this won't have any effect.  Thanks for any help. Dual VGA Cards Intel/ Nvidia This is my first post in this forum. I am new to Linux, just installed Ubuntu 11.10 on my Sony Vaio VGN-Z12 with two graphic cards Intel and NVidia Geforce 9300 GS.  After the installation the lightdm works on Intel card but with very law display quality. I installed Nvidia driver from the official website as well as this PPA.  sudo apt-add-repository ppa:ubuntu-x-swat/x-updates sudo apt-get update sudo apt-get install nvidia-current       Once I installed the driver and run nvidia-xconfig which creates xorg.conf file, the xserver will not start with error "no screen". If I delete the xorg.conf file then I am able to start the xserver normally but with intel display (bad quality) Is the null set a subset of every set? Ever since day one of of my Mathematical Logic course, this fact has really bothered me. I cannot wrap my head around how an empty set is a subset of every possible set. Could someone kindly explain how this is true? Any help is appreciated! $VAR vs ${VAR} and to quote or not to quote I need a shapefile for India which is up-to-date to display the regional borders. By up-to-date (in 2014), I mean that it includes Telangana as a state. Many shapefiles that I downloaded do not have Telangana as a state as it was partitioned a month ago, it is displayed as part of Andhrapradesh.  So I need the latest shapefile. operators as strings I need to evaluate a mathmatical expression that is presented to me as a string in C#.  Example noddy but gets the point across that the string as the expression.  I need the evaluate to then populate an int.  There is no Eval() in C# like in others langugaes...  String myString = "3*4";   Edit:  I am on VS2008   Tried the Microsoft.JScript. = Its deprecated method (but still complies - warning)  However the Microsoft.JScript dll that I have doens work on      public object InvokeMember(string   name, BindingFlags invokeAttr, Binder   binder, object target, object[] args);   Complains that there is a missing ";"  go figure...  EDIT 2  Solution - was the codeDom one - it worked for as there are no security issue - only me ever going to be running the code.  Many thanks for the replies ...  And the link to the new Dragon Book  awesome   EDIT 3  Matt dataTable.Compute() also works - even better for the security conscious.  (parameter checking noted) On webmail every user gets error "ERROR: Message not sent. Server replied: 354" while sending mails.   But mails are sent properly and reaches properly.  Can you tell me where is problem, and why it is occurred?  UPDATE: I found in some resources that this is not an error but standard information message. On the other side, it's annoying. Can you tell me if it is a true, and if it is how can I avoid it? Why is vim frozen? How do I disable "Workspace dock" (a bottom panel with the list of open windows and a workspace indicator-cum-switcher), the one that is over "Plank" in the screenshot below?    I'm using Ubuntu 17.10. Any other words that use “dis-” as an amplifying prefix? I remember hearing once about the etymology of disgruntled, probably based around a joke about how people can not be gruntled. The explanation given was that there was never a word gruntled, rather the dis‑  in disgruntled is actually a usage of the old prefix where it acts like an amplifier.   Firstly, is this true?  Secondly, are there any other words that use this prefix in this way? Detect if an outgoing call has been answered How to prove $a^3 + b^3 +c^3 - 3abc =1 $, If a,b,c are infinite series as given in the description box below? How do I prove that $$ a^3+b^3+c^3−3abc = 1 $$ if   $ a = 1+\frac{x^3}{3!}+\frac{x^6}{6!}......$ , $b=x+\frac{x^4}{4!}+\frac{x^7}{7!}....$ , $c=\frac{x^2}{2!}+\frac{x^5}{5!}+\frac{x^8}{8!}......$ ?  I have tried the following :-  I discovered that $a+b+c=e^x$ and that $a=\frac{d(b)}{dx}$, $b=\frac{d(c)}{dx}$, $c=\frac{d(a)}{dx}$ . But I am unable to proceed further with these information. Why is ${x^{\frac{1}{2}}}$ the same as $\sqrt x $? Why is ${x^{\frac{1}{2}}}$ the same as $\sqrt x $?   I'm currently studying indices/exponents, and this is a law that I was told to accept without much proof or explanation, could someone explain the reasoning behind this.  Thank you. Why doesn't ZIP Compression compress anything? A 398MB directory was only compressed to 393MB using 7Z and Normal ZIP compression. Is this normal? If so, why do people continue to use ZIP on Windows?