7,116 Posted Topics
Re: You already have a method to find the largest value. All you need is exactly that same logic, plus keep a count of the position as you loop. Each time you find a larger value, record the position where you found it. | |
Re: [UCanAccess](http://ucanaccess.sourceforge.net/site.html) (sourceforge) may be an answer | |
Re: Nice example. You can push the Stream usage a bit further, depending on the overall requirements, along the lines of: Files.lines(Paths.get("studentTest.txt")) .map(line -> line.split(":")) .filter(parse -> parse.length == 2) .map (parse -> new Student(parse[0], parse[1])) .collect(Collectors.toList()); | |
Re: What code are you using to process the output stream from your process? | |
Re: JMF is old and never received much love from Sun or Oracle. It never worked properly, and never will because Java 8 includes JavaFX, which is the future of multi-media GUIs in Java. I would recommend you forget JMF and look at JavaFX - there's lots of stuff on the … | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Post what you have done so far and someone will help you from there. | |
Re: (This is a copy of my replies to the earlier thead - repeated here for simplicity) That's a common problem with Swing (or any other powerful GUI toolset), and there isn't any good solution. An IDE with code folding helps when you are editing the code. You can certainly put … | |
Re: I'm not surprised you find it confusing. You are jumping in at the deep end with a number of copmplex technologies all at once, without learning the basics first. Einstein would have found that difficult. (Actually he wouldn't because he was too smart to try it!) Stultuske's advice (at the … | |
Re: hoursWorked is defined and initialised in HourlyEmployee. In class Janitor's constructor you have super(name, hoursWorked); now the parameters of a method (or constructor) are evaluated before the method is called, so this line tries to evaluate hoursWorked before it can call HourlyEmployee's constructor. Because HourlyEmployee's contructor has not yet been … | |
Re: The default access is not public, and public/private are not the only alternatives. See http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html | |
Re: Line 22 you create a brand new new tree for every single word you read. | |
Re: 1. Post your code in CODE tags so we can read it. 2. frame.getContentPane().add(pane); the getContentPane() hasn't been required since Java 1.5 3. Never override paint(), override paintComponent instead. 4. Because your custom JPanel has no components in it Swing doesn't know how big it is, and probably has its … | |
Re: Before you start installing some random datatbase engine, remember that Oracle's JavaDB is already on your system. It's installed as a part of the standard JDK. It works very well indeed with Java (obviously!) and NetBeans knows all about it. You can start with it as a singe-user simple embedded … | |
Re: The parameter for split is a REGEX. In a REGEX the + character is a special character. To use it as a literal + you need to "escape" it with a single \ . To enter a single \ in a Java String you need to code a double \ … | |
Re: If it's Eclipse-based you just have to run your app in debug mode for full execution & variable tracing | |
Re: This is the Java forum. That's not Java. | |
Re: 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 doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) … | |
Re: Hi vishalcap For the benefit of anyone else getting this problem in future, and finding this thread, can you please let us know what the problem was, and how you fixed it? thanks | |
Re: OK, cool it down folks. stultuske is well known for saying what he thinks. If anyone doesn't like his posts then just ignore them. Please don't get into a place where I have to infract anyone for violating the "Keep it Pleasant" rule. Now, back to the original subject please. … | |
Re: Simply placing components on top of each other in an ordinary JFrame doesn't work. There are (at least) two ways to put controls over a background image: 1. Subclass JPanel and override `paintComponent` to draw the background image directly into the JPanel 2. USe a JLayeredPane to place your controls … | |
Re: You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others here. There are lots of people here who will freely give their time to help you become the best Java … | |
Re: What do you want it to do when it encounters a null value in the database? | |
Re: I simply use code like InetSocketAddress addr = new InetSocketAddress("XXX.no-ip.biz", 21); new Socket().connect(addr, 2000); to connect to a host via No-Ip, and it's just like connecting to any other DNS-registered host. No problem. The thing that can be fiddly is getting your server accessible if it's behind a router/NAT, but … | |
Re: Hve a look at System.out.printf - allows you to specify the format for what you print. | |
| |
Re: No no no! Only ever draw on a Swing Graphics when you override `paintComponent(Graphics g)` (or, sometimes, `paint(Graphics g)`) Swing has all kinds of internal optimisation, including double-buffering that you don't see. If you start drawing to Swing's internal Graphics at random times then there's a major risk that it … | |
Re: > Caused by: java.lang.IllegalStateException: Location is not set. > at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) > at javafx.fxml.FXMLLoader.load(Unknown Source) ... seems to suggest there's something missing in your scenebuilder FXML file? Update: It seems this can be caused by the FXML file not being where you told the loader it is. In turn, … | |
Re: Programming is 90+% thinking and 10-% typing, at best. I'm the world's worst typist, but it doesn't matter because I use NetBeans that does much of the typing for me, and identifies typos as I go. My guess is that, as an experienced developer, using Eclipse or NetBeans improves my … | |
Re: This sounds like a cunning re-phrasing of the classic "Travelling Salesman Problem" with its O(n!) time for a brute force solution. There's a vast amount of info on the TSP, including more algorithms than you could shake a stick at. WikiPedia is yopur friend. | |
Re: Why do you think anything is wrong with it? If you have an error, or incorrect results, then share that info with us, don't expect us to guess! | |
Re: 1. Multi-threaded server for multiple concurrent clients: see http://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html (don't miss the bit about multiple clients towards the end) 2. Splitting the message - just use String's `split` method. If that's not good enough then search for delimiters with `indexOf` the use `substring` to pick it apart. 3. Concurrent update … | |
Re: This answwer is a bit late for a 3 year old question | |
Re: Do you really think you have given enough information for anyone to know what you have done wrong? | |
Re: Is this what you mean? class A { public A(int i) { ... // constructor ... } class B extends A { public B(int i) { super(i); // calls superclass's constructor } ... } | |
Re: > Could someone explain this could with deep detail? line by line? I doubt anyone has the time or motivation to do that. Look at some beginner's tutorials, and come back here with any specific questions that may remain. [This](http://docs.oracle.com/javase/tutorial/java/javaOO/classes.html) is a really good place to start | |
Re: Read the Oracle tutorial http://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html in particular, see the comment under `weightx, weighty` about half way down. | |
Re: There are lots of ways to do this, here's one that is easy to read... have an `isNumeric` boolean. Start with it true, then set it false in the catch clause if you get a NumberFormatException. Put the messages (lines 15 - 23) inside an `if (isNumeric) ...` | |
Re: Add ActionListeners to the buttons of the second window. | |
Re: So `GameKeys.mouse[0]` is null, meaning you ctreated the array but you didn't initialise its elements. Maybe you just forgot to do that, or maybe one of your events is being called early in the startup, before you have finished initialising that array? | |
Re: I didn't see why that would fail, but have you tried printing `ability` at each of those stages to see where the null creeps in? | |
Re: Time consuming to program? Yes, very. You'll probably end up with a complete java source code parser plus a raft of individual rule checks - all of which is perfectly do-able in Java, but it's going to be a *lot* of tedious code. I know there are compiler-compilers and generalised … | |
Re: Yes, people here will help - but do read the DaniWeb rules first, especially "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules | |
Re: Please give a proper description of what should happen ve what actually happens. | |
Re: Let me just add the usual health warning to the previous post. anand.khatik is a first-time poster; we have no information, good or bad, about his skills or credibility. Nobody has checked the email address he gives. Anyone copying someone else's code and submitting it as their own homework deserves … | |
Re: You don't need an IDE, but if you are going to use one NetBeans seems to have integrated it better. JavaFX comes with a drag'n'drop GUI builder called SceneBuilder that you can use stand-alone or in your IDE. Yes, you can (probably should!) add the GUI to the logic layer … | |
Re: Your classpath needs to contain an entry that refers to the jar or folder that contains the missing class (in a folder structure that matches the package names) | |
Re: Your subclass overrides the superclass's toString() so that doesn't get executed. You could do something like public String toString() { return super.toString() + "\n Country name: " + countryName + "\n" + "Population: " + population; } ps: I guess you realise that a Country is NOT a subclass of … | |
Re: The question to ask is "which variables MUST be set for the instance to be in a valid state?" Eg Maybe every Emplyee MUST have a name, but maybe a title is optional. Maybe every Worker MUST have an hourly rate, but maybe it's OK to default the hours to … | |
Re: C++ is a language with a standard librray that covers a decent range of common requirements. You are expected to use it with the native facilities of your OS and whatever other third-party libraries you need to build your application. Java is a language plus a vast API of over … | |
Re: Start by defining a Student class that has instance variables for name. marks etc. Input the raw data, create the instances of Student and add them to a List like JeffGrigg said. Java has methods to sort a List: http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#sort%28java.util.List,%20java.util.Comparator%29 you need to create one or more Comparators ( http://docs.oracle.com/javase/7/docs/api/java/util/Comparator.html … |
The End.