7,116 Posted Topics
This is a little discussion/example of design for modularity and re-use, inspired by javaAddict and Orlando Augusto posts in their thread “Dynamic Multidimensional Array Printing” https://www.daniweb.com/programming/software-development/code/305580/dynamic-multidimensional-array-printing That thread has 3 solutions to printing the contents of a multi-dimensional array of arbitrary dimensions - although in fact all the solutions will … | |
Re: Neater to use the modern Java for-each loop: [CODE]for (Object o : obj) { ...[/CODE] rather than the old C-style looping: [CODE]int length = Array.getLength(obj); int i=0; // NB this is redundant! for (i=0;i<length;i++) { Object o = Array.get(obj, i); ...[/CODE] | |
Re: Do what you are supposed to do and write it yourself. Coming here and making rude demands is not the way to go. https://www.daniweb.com/programming/threads/435023/read-this-before-posting-a-question | |
Re: You made the right decision - his reply just confirms that. ![]() | |
Re: If you don't know if the code is c, c++, or Java then it's hard to take this seriously. | |
![]() | Re: It's interesting that the stack for your error doesn't include any of your code - it's just Swing re-drawing the JTable. So the exception is NOT being thrown from any code that you wrote. The implication is that you, at some earlier time, populated a cell that should be numeric … |
Re: Hi newbie. I remember this! If the queue keeps growing then the real problem is that you are processing database updates more slowly than new transactions are arriving. Messing about with threads and queues around the input won't change that. I don't fully understand the changes you propose, but I … | |
Re: Exactly which output is wrong, and what exactly does it display? | |
Re: Before going too far down the reinventing-the-wheel path, have a look at Netbeans, eg "Insert code..." | |
Re: I’m all in favour of this idea. I’ve seen far too many posts here from beginners struggling or failing with Scanner, so an alternative is much needed. David has has posted a whole load of code, but I'm going to ignore that for a moment and try to continue the … | |
This class is intended as a small and simple alternative to java.util.Scanner for people in the early stages of learning Java. Unlike Scanner it has built-in error handling and retry, it throws no checked exceptions, is as tolerant as possible of variations in the format of user input, and avoids … | |
Re: Read this before posting: https://www.daniweb.com/programming/threads/435023/read-this-before-posting-a-question | |
Re: Read this before posting: https://www.daniweb.com/programming/threads/435023/read-this-before-posting-a-question | |
Re: Maybe sort the list based on the first value. Then it's trivial to find consecutive entries that are within tolerance for the first value. For each set of such entries sort it by the second value and find the subsets that are within tolerance for the second value. Replace those … | |
Re: If you want help you must explain what you are trying to do, and exactly what help you need. | |
Assertnull and I have cooked up a little Java utility that we think will be useful for early-stage beginners, and I'm planning to post it for anyone to use. Is there some preferred short copyright/ownership/licence statement that I should include at the start of the code? I know that Daniweb … | |
Re: The error message should include a line number... that's important Anyway, line 82 of the second class refers to mortgage, which is a variable in the first class. You don't need that to call a method in the same class. You can just say calcC() | |
Re: This code includes a copy of a "Console" class that has popped up a couple of times recently. Maybe the work of David W. ? It's obviously intended as a replacement for the dreaded Scanner class, so I'm all in favour of that! Before it gets too widely copied & … | |
Re: Maybe its because your layout manager isn't updating to include the new JLabel until you force it by re-sizing the window. Try calling revalidate() (and maybe also repaint()) after adding the JLabel | |
Re: I'm not good at regex, so I often start by removing all the white space (one simple method call) so what remains is easier to parse. | |
Re: If you "finished it" by using the hundreds of lines of code from David W then you are deceiving yourself. All you wil have done is to get through this exercise without learning the skills it was supposed to teach, which means you will be in an even worse state … | |
Re: `results` has just two entries (see lines 11,12). You can add stuff to the maps that they contain, but there are still only two entries in `results`itself Try printing the contents of all your maps to see what's going on - at first sight I think your code is doing … | |
Re: Have a look at the JavaScript support in Java - it allows you to run javascript (and other scripting languages) dynamically from your Java program while sharing varaiables and objects between the two. So you can pass javascript in a String along with any Java values or objects, execute it, … | |
Re: > to protect you from yourself so you can't screw anything up. Just don't touch it. You don't need to touch it or know about it or care about it. It's for me, not for you. Well, yes, that's about as inflamatory answer as anyone can give their boss or … | |
Re: > id like to know the java program of this one We do not do people's homework for them. Try to write it yourself. If you get stuck post what you have done so far and explain what help you need. | |
Re: Maybe a small point, but naming is ever so important in OO implementations... Would that class not be better called "Connection"? | |
Re: A course will teach you a specific technology. The knowledge you gain will be out of date soon afetr you finish the course. Whatever is "booming" today will be "boring" in a year or two. Your career will continue for decades. So rprofit is right. Get as wide a range … | |
Re: Trying to use dubious tools when you don't understand the underlying code is a really bad idea. At best you'll get some result that you won't understand, at worst you'll just get more and more confused. GridLayout is really simple to use. You don't need any tools. Just read the … | |
Re: I'm with stultuske on this one. Looking at your posts here you are trying to do way too many things at the same time. Stop messing about with frameworks and code repositories and concentrate on mastering the basics of Java coding. | |
Re: You had a good answer 22 hours ago. | |
Re: Arrays are not easy to use when you want to have a growing list of values like that. You need to start with a large array, and have a separate counter that tells you how many values you have actually used so far (initially zero). The counter then tells you … | |
Re: If the program won't compile then its utterly pointless trying to execute it. If it doesn't compile tell us what the error is and on which line. Don't expect us to guess. | |
Re: "I assume i do something wrong" tells us nothing. If you have a compiler or runtime error message post the complete message plus the actual code it refers to. If your code is giving an incorrect result explain what result you get and what the correct result should be. | |
Re: You have a load of get methods that change the values of your variables, eg public double gethoursWork() { hoursWork = hoursWork * rateOfpay ; return hoursWork; } now suppose hoursWork starts out at 10, and rateOfpay is 8 call getHoursWork and it will return 80 call it again and … | |
Re: Client line 19 you use `write`, which just writes the low byte of its int parameter, but in the client you `readInt`, which neeeds 4 bytes, so the `readInt` is still waiting for the last 3 bytes. | |
Re: Hey yes, welcome. Get started by helping to answer other people' questions, or asking sensible questions of your own. The more you put in, the more you get out. | |
Re: Seems bizarre that an extra R.P. is diagnosed as "missing" :) | |
Re: You will need the window with the back button to have a reference to the other window that needs to be closed. Then you can call that window's dispose method... JFrame otherWindow = // a reference to the other window backButton.addActionListener(e -> { otherWindow.dispose(); this.dispose(); }); | |
Re: Maybe that is overkill, maybe not, but in any case, starting with OP's tables, they need at least some kind of foreign key to relate Bills to Consumers. Without that the problem has no solution. ![]() | |
Re: > basic tenants of software object based design, and a little about how developers communicate and work together A key idea here is that objects have a public interface and everything else is encapsualted (hidden) inside. So developers need to discuss and agree those public interfaces. In general they don't … | |
Re: If you are measuring network packets then the OS code involved in receiving those packets will be orders of magnitude more than anything you are adding. Just make sure your code is maintainable, that's all you need to worry about, | |
Re: Well done! In general, yes, install the latest SDK and wait for everything to re-build, then change the settings for each project where you want to use JDK 8 features. At least yur JKD7 code will still compile & run using Java 7 rules & syntax, but without the unfixed … | |
Re: It's a real problem with Scanner's design - so many people fall into this trap. You have some input with an int followed by some text, eg 101 John Doe ... and you try to read it with int num = scanner.nextInt(); String name = scanner.nextLine(); ... and name is … | |
Re: If you know Java then JavaScript is just like a children's version of Java and you can pick it up in no time at all. Do that anyway, becuase Java at the server is so often used with JavaScript at the client. Java is absolutely massive in the web server … | |
Re: Seriously? You're doing a dissertation for a Master's degree and you don't know how to use Google search? Go away and do some work yourself. If/when you get stuck you can come back here with your specific problem and people will try to help you, but nobody is going to … | |
Re: You just copy/pasted your assignment without even a moment taken to explain what help you need. There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or … | |
Re: dividing by 100 is not the same as multiplying by 0.1 | |
Re: > only 8% of our overall traffic is on mobile. Chicken or egg? Surely nobody would develeop a new networking environment in 2016 without supporting Androis and IOS devices! ![]() | |
Re: I was Principal Consultant with Easel/VMark after they acquired the Enfin Smalltalk implementation (now part of Object Studio) in the 1990's. The claims made for Smalltalk are largely true. It was my first intro to formal Object Oriented programming and I never looked back. It was truely ground-breaking, and highly … |
The End.