7,116 Posted Topics
Re: 1. Do not hijack other people's topics 2. Do not revive years-old topics 3. Never ask others to do your work for you If you would like help in doing the conversion yourself then start a new topic, and explain what you have done/tried so far. | |
Re: Ken_10 and anyone else who thinks like that: Getting someone to do your school work is stupid. You'll learn nothing and just waste the opportunity for education. It also penalises genuine students who are competing with you using their own effort and skills. You're also like to get caught and … | |
Re: You can... `import static java.lang.Math.PI;` and refer to it as `PI` or don't use an import and refer to it as `java.lang.Math.PI` in your code. Why??? | |
Re: i've been running the ARM version on an M1 Mac with Parallels and wow, is it fast. As a Mac user I love the new look with the soft corners etc - the blocky graphics of 10 look just like Windows 95 but without the hardware limitations to justify it. … | |
Re: I love the way these posts reveal little goodies hat have slipped into Java over time. I failed to notice `String.indent` (new in Java 12), and that also lead me to discover `stripIndent()` which arrived with Java 15. I also love String's` formatted(...) `method (new in Java 15) that works … | |
Re: > The filter() and map() methods automatically perform the Optional emptiness check for us, and return an empty Optional object downstream Thank you so much for this little gem. I was always disappointed with Optional, too much overhead and verbiage compared to the `?.` syntax of some other languages. But … | |
Re: Googling "pin block encryption java" got me. lot of hits. Is that what you meant? | |
Re: Its a very bad idea to have multiple Scanners usig the same input stream (System.in). You never know which Scanner will read the next character from the stream, or which Scanners may have read ahead and thus consumed characters that you hoped to read with a different Scanner. Create just … | |
Re: Good stuff. In addition to the above, I'm a big fan of the classes in Collections.unmodifiable , eg Collections.unmodifiableList. Collections.unmodifiableMap etc Anytime you need to give limited access to a private Collection just provide a getter that returns the Collection wrapped in the corresponding Collections.unmodifiable. Now the user can see … | |
Re: Welcome - and please accept, with my compliments, the mantle of "Oldest Old Timer". That was me, until you joined, but at only 73 and never having programmed in less than 16k (IBM 1130) you trump my stats convincingly. Like you I still code as a hobby (and to help … | |
Re: Maha Your rude demand for someone to drop whatever they are doing and do your homework for you is attached to a 10 year old dead topic. so 0/10 for post quality. Think on your mistakes, start your own new topic and show some courtesy and some effort, then maybe … | |
Re: AFAIK there isn't anything, which is why I hacked this together a while back. Feel free to use it without any warrenty. SImply call `ConsoleWindow.withInput();` and continue to use System.out (or err) as usual. Read from System.in as usual, eg via a `Scanner`. import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import … | |
Re: half your life / 10 years sitting at a terminal hardly qualifies anyone as a "renaissance man"... > the term Renaissance man, often applied to the gifted people of that age who sought to develop their abilities in all areas of accomplishment: intellectual, artistic, social, physical, and spiritual. (WikiPedia) | |
Re: As was the case with manual labour, smart machines will increasingly offer better price/performance than humans over more and more activities, replace them, thus creating more unemployment. That will be true not just of existing jobs, but also any new jobs that the change creates. In countries with an ethos … | |
Re: I don't think there's anyone here who can do that for you. You should contact Apple directly. | |
Re: Hi Dimitrilc OK, thanks for the reply. That's what I thought, but I just wanted to check that I hadn't missed something. It is 100% valid Java, even if it's redundant. My preference is in the 60% who would skip it, so when I saw it there I immediatley started … | |
Re: Keyboard handling in Swing is always a challenge because the focus is often not where you think. You can often get round that by creating a keyboard handler and adding that to all the components where it could possibly make sense. The "right" solution according to Oracle is not to … | |
Re: Which thread is that method running on? If it's the Swing thread (eg because it's responding to a button click) then it will hold up all Swing activity until it returns. Only after the method returns will Swing perform all those visiblity changes, and probably optimise them ot of existance … | |
Re: Short answer: small projects (eg < 1 man-month) rarely need interfaces or abstract classes, but large projects use them to define exacty how different parts of the app will communicate with each other. [This section](https://docs.oracle.com/javase/tutorial/java/IandI/createinterface.html) from Oracle's Java tutorials explains it pretty well. | |
Re: IF your plan is to do nothing, wait until the day before the cutoff, then expect someone else to drop everything and do it for you... ... then nobody here is qualified to give you the kindof help you really need. | |
Re: i think you'll find that still adds the -1 to the total before exiting the loop. Given the need to exit the loop after validating the input but before processing it I would suggest this pattern: while true get and validate input if (input = SENTINEL) break; process input | |
Re: For what it's worth I tried a little test in Java and the AES encrypted output was always the same for the same input values. I'm no expert, but from my reading of a few web sites the algorithm looks like there is no dependency on anything other than the … | |
Re: Two problems with that code: It creates a second Scanner (line 20). Two Scanners on the same input stream is a formula for chaos. Either of them may read ahead from the stream thus preventing the other from seeing those characters, with unpredictable results. One program -> one Scanner(System.in). It … | |
Re: Your "correct" progam fails to remove the zeros. It just overwrites them and stops printing before it gets to the original values left at the end of the array. As for the quality of the code, including Java naming convention, formating and indentation, it's maybe some of the worst code … | |
Re: I think they are looking for a simple trainee exercise, not a commercial-grade full system. What's "Java 2"? We're currently on Java 15. | |
Re: In Java hashes are calculated by the `MessageDigest` class. Here's the documentation: https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/security/MessageDigest.html Come back here if you need help after taking the time to read and understand that | |
Re: The close bracket on line 4 ends the class definition, so whatever follows has to be a new class/interface/enum. Line 7 attempts to define a method inside the method definition starting on line 5. You cannot nest method definitions. Plus (not exectly errors, but bad style): Class names should be … | |
Re: where to start? Start with design. Classes that represent the nouns of the probem domain with their public interfaces that model the verbs. Don't worry about code yet. Here's a good site that talks through how to do that: https://www.eventhelix.com/object-oriented/object-oriented-design-tips/ | |
Re: I'm frankly baffled by the requirement for a `static void` method to calculate what should be an instance variable, using existing instance variables. It makes absolutely no sense. | |
Re: An ArraylIst of ArrayLists is like a 2d array. Which means that there's no single definition of what it means to sort it. Eg Sort each sub list ? sort the sublists within the main list according to some criteria ? sort all of the data and store the result … | |
Re: I can assure you that += does work if you use it correctly. Without seeing your code there's nothng mre anyone can do to diagnose your problem. Post the code. | |
Re: Hint (also applies to your other thread): You can get the nth element in a List as follows: `list.get(n)` | |
Re: take a moment to think through the value(s) of j on lines 6 and 7. on each pass of the loop you do the whole calculation for just one value of j, then you do that multiple times. pseudo-code the solution on paper and step throught it a couple of … | |
Re: Go to adobe.com and purchase the kind of licence that suits you best. | |
Re: What exactly is the point of this? How many people are going to do a clean install of WIndows 10 on a 32 bit machine in 2021? To quote Microsoft: "Beginning with Windows 10, version 2004, all new Windows 10 systems will be required to use 64-bit builds" | |
Re: Which line and variable does the NPE refer to? | |
Re: It seems like it's looking for your java file in the wrong place. It's looking in c:\Program Files\java, presumably because that's your working directory (?). That's a really bad place to put your own source code projects. What directory is Main.java in? What exectly is the command you are using? … | |
Re: looks like a simple array sort to me. If so the pseudo code is already well known and you just have to match it to the details of this implementation | |
Re: The instructions are almost pseudo-code for the actual solution. Each sentence represents a few lines of code, all in the right order. So start with "Read from the user the number of cities " and code that, then go on to the next line. If you get stuck come back … | |
Re: That looks like fun! To see if I understood it correctly I tried a Java version. Before I publish it maybe you could validate it by decoding the following: key = "DaniWeb" data = {-87, 8, -88, 77, -110, -100, -123, -1, 86} cheers J | |
Re: I've been programming in Java since the mid-90s (working for HP Consulting), and programming since 1969, but I'm not prepared to call myself a "master". The more I learn, the more aware I am how much I still don't know. Anyway, my first answer is that the only way to … | |
Re: I can't see anything wrong with that code. I pasted it into a little stand-alone test and it works perfectly... JFileChooser fileChooser = new JFileChooser(); int result = fileChooser.showOpenDialog(null); File f = fileChooser.getSelectedFile(); long time = f.lastModified(); System.out.println(new Date(time)); | |
Re: [CODE]NOTE: I've not write the Exceptions yet .. I will do when every thing work ..[/CODE] There may be a more stupid thing posted this year on Daniweb, but I doubt it. How can you possibly try to debug your code when you chose to ignore any and all arrors … | |
Re: > Java/ Javascript is usually client side There's no such thing as "Java/ Javascript" javascript is client side. Java (not the same thing) is used for both, but the majority of Java development today is corporate server-side. | |
Re: > 9999999999 That's 10 digits, not 7 and as such can hold values > 2^31 which cannot be stored in an int. (Although I have no idea if that is actually the problem. Just sayin') | |
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: Maybe the problem is that `choice` is still zero after a failed `nextInt()`, thus exiting the loop. Try setting `choice` to some other vaue (eg -99) in the `catch`. | |
Re: This is presumably all about passing params as references rather than values (the default in C#) To pass a parameter as a reference use the `ref` keyword. See https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/passing-parameters |
The End.