7,116 Posted Topics
Re: I think that sos's point was that you shouldn't have to perform that kind of cast. It probably results from a bad design decision. The "correct" solution is to declare the List(s) appropriately with a `? extends ... ` In this particular case the Lists on lines 17 and 21 … | |
Re: Yes, one of the easiest ways to detect duplicates is to use a Collection that does not allow duplicates, eg HashSet. Its `add` method returns false if the set already contains that element. | |
Re: > Hint: Count the steps while traversing the list until encountering position p > isnt it put the method Iterable positions();? Yes. Simply use positions() to loop through the elements incrementing an index and and test each until you find the one you want. Then return its index. | |
Re: Seems to me that the essence of "hacking" is to gain access to some resource or capablility that the original software developer did not want you to access. As such it's always going to be crimially illegal and/or a violation of the original software's T.O.S. As such I would leave … | |
Re: JavaDB is just Derby, which moved from Oracle to Apache where it is still very much alive. The most recent release was March 1st 2021 (!) https://db.apache.org/derby/ | |
Re: Where do you add the JPanels to the JFrame???? | |
Re: You should explain EXACTLY what "does not work properly" means... eg what error message do you get, or how does the output differ from what you expected. Anyway - for the moment I notice that you have `grades= nextInt();` in 3 places and after two of those you never use … | |
Re: Recognise that best AND easy doesn't exist. Oracle's own tutorials are (IMHO) the best - start [here](https://docs.oracle.com/javase/tutorial/getStarted/index.html) As for easy - there are loads of beginner tutorials on the web - mostly out of date and often downright wrong - but OK if you just want a warm fuzzy hand-holding … | |
Re: Your while test is wrong... while grades<= zero AND >= zero. Grades can't be both those at the same time (unless it is == 0), so the test is false and the loop never gets executed. Because the loop isn't executed you never increment `count`, so that stays at zero. … | |
Re: Hint: `for (Account acc : gBank) {...` this loops through all the accounts, setting `acc` to refer to each account in turn so in the loop you can use `acc` with all the public methods of the Account class, eg for (Account acc : gBank) { if(acc.getOwner().equals(me)) acc.deposit(lotsOfMoney); } | |
Re: All you NEED is the Java Development Kit (JDK) and a text editor (any text editor). IDEs like Eclipse and NetBeans are used by real programmers because they provide all kinds of integrated productivity tools BUT they come at the cost of a huge learning curve. You will find it … | |
Re: You need something like (pseudo code) while there is more input available read coordinates i and j M[i][j] = 1 | |
Re: First, those are two completely different concepts. Overloading is a convenience thing. Use it when you have a method that could be used with different paameters, eg an internet thing that could use an IPV4 or IPV6 address. You could have two methods with slightly differenet names, but the code … | |
Re: You use the new shuffled array to provide N index values in random order. You use those index values to index into all the other arrays. In other words - on line 7 above you set `x` to be the next value in the shuffled array of indexes. | |
Re: That's a reasonable start. Some errors to fix, and some functionality to implement. What's your question? | |
Re: That's going to map pretty closely to the Java equivalents, so whats stopping you? ps: That multi-line string delimited by triple quotes had no equivalent in Java until Java 14 or 15, so make sure you are on the latest version. | |
Re: ? If you just have 1 thread, using an executor or not, then there's no concurrency issue. If you create two thread instances with the same FutureTask instance and start() them simultaneously then you are open to concurrency problems. I can't think of any reason why someone would do that … | |
Re: > You may have Java 15 installed, but according to your screenshots, you are using Java 8 It's more bizarre than that. The java version is 1.8 but the compiler is 1.15 Possible reason is that a 1.8 JRE (runtime only) was installed, followed later by a 1.15 JDK (full … | |
Re: OK, I looked. It's a standard "complete the code" learning exercise. How far have you got? What have you tried? Exactly what help do you need? | |
Re: All very technical and graphical.but until you give me at least one practical use, I'm not interested | |
Re: If you store it as a 2D array in Java then it's easy. Remember htat a 2D array is really an array of arrays, so all you need is the check that the `length` of each inner array is the same as the `length` of the outer array. No need … | |
Re: Hi Please post your code in the thread here so pleaple can see it easily. Depending on what your question is you may not need to post the whole thing. Use the code block button (the one after B and I) to format and line number it properly. Explain exactly … | |
Re: > tell me how i insert data in to data base, how to select the data in the database There are many many tutorials on the web that cover this very basic information. Nobody here is going to write a new one just for you. Do some research of your … | |
Re: I was running on the last couple of Betas, and switched to the release version with no regrets. The only problem I hit is that NetBeans crashes on startup, but IntelliJ is just fine, so IDC. M1 for Xmas? | |
Re: At line 48 you have `eElement` so you can use that to test for the ID (or whatever) you are interested in and print or not print accordingly. | |
Re: The disturbing thing is that Trump, and most Americans, think they are the world's policeman with the right to intervene and kill people they don't approve of in a foreign country even when they do not present a clear and present threat to the USA. (IMHO the USA should support … | |
Re: What is the "much better technology"? MacOS - better, but a LOT more expensive Windows - more popular, but not necessarily better. And again you have to pay for it. And what's wrong with Linux anyway? | |
Re: Hi shamsudeen98, welcome to DaniWeb You have posted some code to a topic that has been dead for 9 years! The code itself is full of errors, so why did you post it? If you posted it as a solution to this topic then you should have tested it first … | |
Re: Re IOS GM/release The reason developers are upset is that every major release breaks something, and until you have the GM you cannot test for regression bugs or other problems. Ie: users are updating to an OS for which you have not been able to perform proper testing of your … | |
Re: I'm going with "can be done" - at least in theory 1. Excel supports 1 million rows 2. Even London has (only) 32 thousand streets ( https://www.proviser.com/uk/towns/london/street-map ) 3. Some streets in London have 2 or more names ( https://www.maps.thehunthouse.com/Streets/New_to_Old_London_Street_Name_Changes.htm ) | |
Re: Interesting I wait months for a Java question, but I'm not a "Suggested Answerer". Guess I must be really out of favour at DaniHQ. Or maybe it's just that I'm too old (2019 years old according to my profile). | |
Re: Do you have any possible excuse for coding `if (con == true ...` instead of `if (con ...` | |
Re: If this is you final year project then aren't you supposed to write it youself? | |
Re: The `elseif` on line 17 pairs with the `if` on line 6, so where's the `if` that goes with line 13's `elseif`? | |
![]() | |
Re: I'm with rproffitt. Opera Developer version includes a free built-in VPN. Couldn't be easier, couldn't be cheaper. Great for Pirate Bay if you live in a repressive country like the UK. | |
Re: I agree 100% When I look at latest posts, or Java posts or whatever I want to see them all. If I want to filter I can. but the default "recommended" is worse than useless. Please make it remember my choice of "none". | |
Re: Hard to read with no indentation, but it looks like the function at line 27 has its return statement inside an if test, so if the if test fails control will evntually drop through to line 35 where the function finishes without having returned an int. | |
Re: It's commendable that you took the time to reply. However, the topic title and the origional post clearly asks for a discussion of 2-dimensional array *as argument*, and the content you posted covers declaration, referencing, and initialisation, but does not address that question. | |
Re: voogos what you are discussing is called cheating. Lie to your teachers, degrade the efforts of your honest colleagues who actually do the work, waste the chance to learn for yourself, deceive uourself and others about your abilities... What do you do in your spare time? Rob grannies? | |
Re: Yes, that's true... but did you have any particular reason for sharing that today? | |
Re: Following on from fearless' suggestion... I'm not sure about Python, but this looks like a using a *factory*, Typically that's for a constructor, but there's no reason not to use it for any complex method call. Eg: suppose it's a car search where you can supply manufacturur, engine size, fuel, … | |
Re: I don't know firebase, but as nobobdy else has answered.... MAYBE there's a time attached to that data, eg 30-5-2019 10am 31-5-2019 11am and your query is defaulting to midnight, ie 30-5-2019 00:00 to 31-5-2019 00:00 ??? If so the fix is to end the date range with a date … | |
Re: You cannot add a speed and a vector. They are different measures. It's mathematically impossible, like trying to add a length to an area. You *can* add a vector, as in i have X,Y(10,20) and the change is is (2,3) , the addition will be: X = X + 2 … | |
Re: > The scope of a local variable declaration in a block (§14.4) is the rest of the block in which the declaration appears (Java Language Spec 6.3) So the exibited behaviour is what the JLS requires, depending on how you see the multiple assignment, but 4.12.3 seems to clarify that … | |
Re: Which comment are you referring to and what info do you want to remove? There are situations in which a mod can edit for you, provided it's covered by the DaniWeb rules. | |
Re: As a guess: Your run method contains an infinite loop, so if you call it directly it will never return and the calling program will be frozen. So you need to execute it on a different (new) Thread. (That's why it's called "run" - it implements the Runnable interface that … |
The End.