-
Replied To a Post in Application to save word/sentences to file
No. `new File(...)` does not do anything at the system level, it just creates a Java File object, and therefore can't throw I/O related exceptions. It's not until you try … -
Replied To a Post in sorting a sorted list
Lines 1-4 of your code set up the random data. Lines 7-21 do the sort and report the timing So repeat lines 7-21, but don't repeat lines 1-4 -
Replied To a Post in sorting a sorted list
Create the random data run the sort and see how long it takes now run the sort again - this time the data will already be sorted - and see … -
Replied To a Post in need help with a counter
SO what have you done so far? -
Replied To a Post in Birthday Paradox
rproffitt: Is this better? int[] noOfPeopleWithThisBirthday = new int[366]; loop i=0 to number of tries noOfPeopleWithThisBirthday[random.nextInt( (i%4==0)?365:366)]++ now check array for number of >1 entries etc (not valid for people … -
Replied To a Post in parsing text files in java
After the split you have each item in its own array member, so just index the array to get the field you want. To get the average add up all … -
Replied To a Post in Application to save word/sentences to file
How big do you see this file getting? If it will always fit in memory (say just a few hundred meg) then you can do all the appending editing or … -
Replied To a Post in parsing text files in java
One way to parse lines like that is to use String's `split` method with a one-or-more-blanks regex as the delimiter -
Replied To a Post in Birthday Paradox
With exactly 365 possibilities, why not keep it really simple and use an array int[] noOfPeopleWithThisBirthday = new int[365]; loop number of tries noOfPeopleWithThisBirthday[random.nextInt(365)]++ now check array for number of … -
Replied To a Post in Reverse Programming Problems
Here's a Swing-based one... public class QQQ implements java.awt.event.ActionListener { private Preferences prefs; private JComponent parent; private String prefsItemName; private Runnable changeCallback = null; private ButtonGroup group = new ButtonGroup(); … -
Replied To a Post in Birthday Paradox
[edit] ; see invisal's post below for a better explanation of loop problem 100000.0 is a double constant, so the aithmetic is done in double precision, then you assign it … -
Replied To a Post in Reverse Programming Problems
public class SortedVector<E> extends Vector<E> { // Quickie convenience class for a Vector in a defined sort order. // Performance should scale linearly with size. // // The constructor for … -
Replied To a Post in Reverse Programming Problems
Do you mean stuff like this (class name changed, comments deleted) to make it less obvious) public class QQQ<E> extends Vector<E> { private static final long serialVersionUID = -1859832140413652455L; private … -
Replied To a Post in Read 16 byte data from ByteBuffer
Then maybe you could try reading the 16 bytes one at at time and storing them in reverse order into byte[16] array, then use that for the BigInteger constructor call? … -
Replied To a Post in Read 16 byte data from ByteBuffer
16 bytes is 16 bytes. How you read them depends on what they represent and what you want to do with them. What are these bytes? Are they a signed, … -
Replied To a Post in GridBagLayout: can't see my components
The "enhanced" for loop is generally considered eaier to read and harder to get wrong. but it's up to you. The thing with method signatures is that ideally a Java … -
Replied To a Post in GridBagLayout: can't see my components
In my opinion you should not make a window any bigger than it needs to be unless it's modal and must be noticed. You cannot know what else the user … -
Replied To a Post in GridBagLayout: can't see my components
Should be. Just try it. -
Replied To a Post in GridBagLayout: can't see my components
> or default based on ther content JLabel and JButton set their (preferred?) size to fit the text that's in them when you pack(). Sometimes you want to start out … -
Replied To a Post in logical errors cant figure out
If you simply take every block of code iside those loops/ifs that is more than 3 lines long and put those in separate well-named methods then you will be able … -
Replied To a Post in GridBagLayout: can't see my components
In GBL each child has a position row/col and a size (in units of rows & cols), so if you have something at (1 ,1, 1, 2 ... thats position … -
Replied To a Post in Java 8 Stream
That's quite likely. You are replacing low-level procedural code (loops etc) with higher-level declarative code. However, I think you would have to be processing a lot of data for any … -
Replied To a Post in Create sequence diagram from use case in Rational Rose
Are those actual classes across the top (apart from User)? You don't seem to have any feedback to the user at each stage. Is that what the use case specifed? … -
Replied To a Post in Java 8 Stream
Welcome to Java 8! That code seems to have acumulated some extra code, presumably from trial-and-error. I took your code, added a litte constructor to Order, and set up some … -
Gave Reputation to April Jam in Java First-Fit & Best-Fit
HI, I THINK THIS MIGHT HELP YOU. [Click Here](http://blog.creativeitp.com/posts-and-articles/java/first-fit-algorithm-in-java/) -
Replied To a Post in Should array be used?
Interesting... This exact requirement can be handled without storing all the input values, so it doesn't need an array (or list). What's interesting is what happens when the next exercise … -
Replied To a Post in GridBagLayout: can't see my components
Hi, it's me again (still on the road, so no JDK to check things). There's no need for extra panels to do this in gbl. Looking at the code again … -
Replied To a Post in Circular shift of words in a string
Not a character array! Split gives you an array of Strings, each containing one word, which is exactly what this project needs. -
Replied To a Post in Java student trying to print an integer one digit per line
what exactly happens when you try to execute it? Do you get any error messages? If you start your main method with a println does that print? If you print … -
Replied To a Post in Create sequence diagram from use case in Rational Rose
Yes, but tag it UML as well. (I'm a huge fan of sequence diagrams as a tool for allocating responsibilities to classes, especially as a group activity around a whiteboard). -
Replied To a Post in GridBagLayout: can't see my components
I don't have a JDK here, but if I remember right you are setting the weights to 1 for the text areas and 0 for the buttons, so all the … -
Replied To a Post in Runtime Exception or Exception
It's your choice. Checked means that any method that calls your method had to deal with the exception somehow. Unchecked means the calling method doesn't need to do anything, but … -
Replied To a Post in Should array be used?
That's how arrays work! You have to know the size to create the array. Java comes with things called Lists, that you can create with no entries, then add as … -
Replied To a Post in Will not print what is coded.
Hi Rahul If you do chose to fix people's homework before them then please take the time to explain what you have changed and why you changed it as you … -
Replied To a Post in counting words in a given text
If you want that level of control over format then inwouldcrecommend gbl -
Replied To a Post in i need help with a program in java
Use a Scanner to read the users input. If you read a single char you can compare it in an if test, but you need quotes round the constant, eg … -
Replied To a Post in counting words in a given text
Ok As for gridbaglayout, yes I use it when I need exact or complex layouts, but I still use border + grid or box or flow + nested panels for … -
Replied To a Post in counting words in a given text
Yes, that's exactly right. We do try to give hints rather than solutions because that's how people learn. But if anything is too cryptic then please ask for clarification. -
Replied To a Post in counting words in a given text
You ignored the problem I told you about. There are two textInput variables, declared on lines 24 and 40 in the previous code. The first one is used throughout the … -
Replied To a Post in Hash map reading from 2 files
I already told you. Use the get method for the appropriate map. Eg After you have loaded the abbreviations and populations into map2, to get the pop for NY, map2.get("NY"); -
Replied To a Post in counting words in a given text
Null pointer exception.... Uninitialised variable. Look at the line it refers to. The only var it could be is textInput. Why is it null? You declare it on line 24 … -
Replied To a Post in Replacing blank spaces with result from another textview
Hi Taywin. Yes, I know the language is the same, but the API is different, especially around program initialisation and the gui. I didn't want to make any assumptions that … -
Replied To a Post in Hash map reading from 2 files
You are supposed to read everything in once at the start of the program. Once it's all in the hash maps you can use their get methods to search them … -
Replied To a Post in Replacing blank spaces with result from another textview
I don't know android Java, but are you sure isEmpty() will be true if the field contains a blank character as opposed to no character st all? -
Replied To a Post in counting words in a given text
mp is a map of strings to integers, so the arithmetic works on the values correctly. tokens is a string, but the value you are adding to is mp.get(tokens[i]), which … -
Gave Reputation to Taywin in counting words in a given text
You are doing it backward if you attempt to implement the program in GUI before you complete the program logic. Did you learn it this way from a classroom? Or … -
Replied To a Post in How to write method for writing output text file?
Write file seems to be doing some ordering, despite the instructions. Read file seems a bit convoluted. If you can assume that the file does just contain ints then you … -
Replied To a Post in counting words in a given text
Anonymous classes are good if they are small, but if they are more than few lines the code gets hard to read, in which case a named inner class is … -
Replied To a Post in netbeans8.0.2
Tomcat and Glassfish are part of the standard EE download -
Replied To a Post in netbeans8.0.2
Yes, you should download and install Java EE
The End.