I have a JFrame and a bunch of JTextFormattedField fields.  The initialization for each JTextFormattedField is the same, so I'd like to have a private method that I call for each JTextFormattedField.  This is what I tried to do:  JFrame Initialization:  myJFrame.getContentPane().add(addCharTextField(m_textField1, new textFieldFocusListener()), "cell 3 1 2 1,growx"); myJFrame.getContentPane().add(addCharTextField(m_textField2, new textFieldFocusListener()), "cell 3 2 2 1,growx"); myJFrame.getContentPane().add(addCharTextField(m_textField3, new textFieldFocusListener()), "cell 3 3 2 1,growx");   And the text field initialization method:  private JFormattedTextField addCharTextField (JFormattedTextField textField, FocusAdapter focusListener) {     textField = new JFormattedTextField();     textField.addFocusListener(focusListener);     textField.setEditable(false);     textField.setColumns(10);     return textField; }   I think there's might be problem with allocating the member variable after being passed to another method.  Later on in my program when I try to access m_textField1, I get a NullPointerException.  Does the garbage collector delete the JFormattedTextField at the end of addCharTextField?  Is there a way around this, besides allocating the JFormattedTextField back in the JFrame initialization routine?  Even if just for aesthetic purposes, I really wanted the initialization for each member variable in the JFrame initialization method to take up just one line of code.  Edit in response to this question being regarded as a duplicate:  My questions are: "Does the garbage collector delete the JFormattedTextField at the end of addCharTextField?"  (The answer was yes)  And "Is there a way around this, besides allocating the JFormattedTextField back in the JFrame initialization routine?" (again yes, but ugly).  The chosen answer in the other question that this one is regarded as a duplicate does not answer either of those.  Now after digging into some of the other answers, and reading the comments here, I was finally able to piece together what's going on in Java.  But that does not make this question a duplicate.  For what it's worth, the problem is a fundamental difference in the C++ 'new' and the Java 'new' that was confusing me.  Considering how much other syntax Java borrowed from C++ without big differences in usage, It took me a bit to wrap my head around around the differences between the 'new' usage.
I always thought Java uses pass-by-reference. However, I've seen a couple of blog posts (for example, ) that claim that it isn't (the blog post says that Java uses pass-by-value). I don't think I understand the distinction they're making. What is the explanation?
How to automatically create large number of columns in Excel 2013 I would like to start a new excel spreadsheet, create a column named Column1, and quickly fill in increments, (Column2, Column3 etc) up to Column500. Is there an easy way to do this?   Also is there an easy way to afterwards select all 500 columns and add 10 rows of data to all of them? Why not use development provisioning instead of ad hoc? SQL Server Escape an Underscore How do I escape the underscore character?  I am writing something like the following where clause and want to be able to find actual entries with _d at the end.  Where Username Like '%_d' Show that $a(-1) = (-1)a = -a $. I applied for a 90-day visa and got a long-term visit, single-entry tourist visa. The date given is 09-March-2015, and it's valid until 07-May-2015.  My agent says the 7th is the latest date I can travel to Dubai; once I enter I need to count 90 days. I entered on the 10th of March.    Is it true, or where can I get it checked?    Can I stay for another month, or do I need to leave before the 7th of May? I'm from Western Pennsylvania. Until I moved away, I never realized that when I omitted the to be from phrases like needs to be cleaned, my usage was different than what most English speakers are accustomed to. Is it wrong? What happens to options held during a reverse stock split? I held 1 put option for 100 shares of USO that expires on May 8. Yesterday, USO underwent an 8:1 reverse stock split. My options are now for USO1 instead of USO, but what does that mean?  The strike price hasn't changed, so does that mean that my option will expire worthless as it's unlikely the stock will drop (significantly) to back below the strike price? How to use host names rather than ip addresses on home network? I've a small home network up and running and managed to set up ssh. Can anyone tell me what I need to do to refer to one computer on the network from another by host name rather than IP address (which is what I'm doing now)? Show that there is no solution to the congruence $x^2\equiv3\bmod5$.   I'm not sure if the fact that the only numbers divisible by $5$ are those ending in $0$ or $5$ will help&hellip; Embed data in a C++ program "pros and cons", "black and white", "ups and downs". Always in a fixed sequence, is there a word or phrase for these? Is there a word or phrase for two nouns or adjectives joined by a conjunction (usually "and") in a fixed sequence?        alive and well           fast and furious   hat and gloves   pen and pencil   law and order   wit and wisdom   salt and pepper   bacon and eggs   horse and carriage   Adam and Eve   ladies and gentlemen   loud and clear   heads or tails   yes or no   dead or alive Colors and legend in groupplots/barplot In order to compare three items I use the groupplot command. For each item I have n different criteria to compare.    Is it possible to set the color for each criteria itself? Meaning the first bar in every group goes gray, the second pink etc.. The legend than should contain the n compared criteria.  And... how do I manage to let the whole tikz-picture have a width of 0.9\textwith  \documentclass{standalone} \usepackage{pgfplots,pgfplotstable} \usetikzlibrary{pgfplots.groupplots}  \pgfplotstableread{ nr  fii faa foo a   10  15  12 b   12  18  14 c   13  19  15 d   9   13  10 e   7   11  8 f   10  15  12 }\datatable  \begin{document} \begin{tikzpicture} \begin{groupplot}     [group style={columns=3},         ybar,         ymin=0,         ymax=20,         xtick=\empty,         tickpos=both]  \nextgroupplot[xlabel=fii] \addplot [fill=blue] table [x expr=\coordindex, y=fii] {\datatable}; \nextgroupplot[xlabel=faa] \addplot [fill=green] table [x expr=\coordindex, y=faa] {\datatable}; \nextgroupplot[xlabel=foo] \addplot [fill=red] table [x expr=\coordindex, y=foo] {\datatable};  \end{groupplot} \end{tikzpicture} \end{document} Should I submit https:// and http:// in Google Search Console both with and without the www? In my site I'm redirecting everything (http://, http://www., https://) to https://www.example.com.  Google webmaster tools says: Make sure you add both "www" and "non-www" versions for your site. Also, if you use the HTTPS protocol, add those variations as well.  So I've added all the FOUR versions to google webmaster tools. Is this a correct process? Hibernate has a handful of methods that, one way or another, takes your object and puts it into the database. What are the differences between them, when to use which, and why isn't there just one intelligent method that knows when to use what?  The methods that I have identified thus far are:   save() update() saveOrUpdate() saveOrUpdateCopy() merge() persist() Strange bug with "MessageName[a,b] is not of the form symbol::name ", Debugger & cursor location A Basic Question about Gravity, Inertia or Momentum or something along those lines How to start a GUI software on a remote Linux PC via SSH Sometimes I need to start XMBC media player or other GUI software a one of my PC (small Xubuntu PC used as a media center).  Usually I do this starting a X11vnc server on the remote PC via SSH and than connecting with an Xvnc client to the Xfce desktop.  Is there a way to start a GUI software on a remote Linux PC via SSH?  Thanks! How can I diagnose and repair missing drive space? I have a small ext3 / partition on a 2T drive which appears to have a discrepancy in its free space. How can I determine what is causing it and how it can be fixed.   After trying everything I could think of, I forced a fsck on boot which didn't have any affect.  I have other systems configured identically which don't exhibit this condition.  # df -h / Filesystem            Size  Used Avail Use% Mounted on /dev/sda1             9.7G  8.9G  318M  97% /  # du -shx --max-depth 1 / 5.2G    /  # lsof | awk 'BEGIN {t=0} /(deleted)/ {t+=$7} END {print t}' 0  # tune4fs -l /dev/sda1 | grep -E 'state|Free|Reserve|size|Inode' Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super large_file Filesystem state:         clean Inode count:              2621440 Reserved block count:     131029 Free blocks:              212317 Free inodes:              2487281 Block size:               4096 Fragment size:            4096 Reserved GDT blocks:      639 Inodes per group:         32768 Inode blocks per group:   1024 Reserved blocks uid:      0 (user root) Reserved blocks gid:      0 (group root) Inode size:               128   Edit:  fsck says the partition is 2% non-contiguous.  For comparison to du above (sparseness):  # du -hxs --apparent-size / 4.9G    / Portrait for phone, landscape for Tablet (Android-Layout) Why does the Community user approve and reject edits?