Java Definition and 587 Threads

  1. F

    Java Java Saving Data In File Internal

    Hello I am trying to read data from one activity, save it to a file... and when open another activity I will be able to read that file(by opening it). I searched for tutorials, all they are showing on the same activity. I figured out how the code works.. but I'm not able to understand what will...
  2. E

    Comp Sci Implementing a PriorityQueue w/ a Doubly-Linked List (Java)

    Homework Statement Basically, as the thread title says, I've got to implement a Priority Queue with a Doubly-Linked List in Java. This is an excerpt from the instructions for the assignment: I've assumed that priority is given to larger integers (since it wasn't specified in the...
  3. J

    C/C++ Java vs wxWidgets or GTK+ with c++ for a PC ground station

    I've got experience with win32API but its' a pain in the ass. What else is good for cross platform low level programming of apps, want it to work for PC, linux, be able to handle serial data streams, convert data and do C++ tier things. So far been using processing but that's not powerful...
  4. Kaura

    Java How to Fix Flickering JFrame in Java Minesweeper?

    Hello, I am currently working on a version of Minesweeper that uses Java. Currently the code seems to work relatively well and the game runs properly, however there is an issue. I currently have the set to update the board on every mouse click and release, as these are currently the only actions...
  5. D

    Programs Programming courses useful for physics majors?

    I'm a physics undergrad and was wondering which programming classes are most useful/beneficial; python, linux, c++, java, etc...
  6. S

    Java Any beginning computer programming course (such as for JAVA.

    Not necessarily for JAVA, but in any beginning computer programming course at a college or university: What will the school, or department, or the teacher require of the students? Need the student use their own personal computer for this? Can student do the work using JAVA without having an IDE...
  7. sefiroths

    Java Runge-Kutta method for Simple pendulum in java

    Hi, I'm trying to study Runge-Kutta method and apply on a simple pendulum. Using a timestep dt=0.1 (h=0.1) the pendulum increses energy of 1% every period... while in this site: https://www.myphysicslab.com/pendulum/pendulum/pendulum-en.html decreses energy about 0.01% What am I doing wrong...
  8. E

    Returning an array of generic type

    This is a homework problem, so I have to follow some stipulations, namely: The problem is, I have no idea how to get a method to return a generic-type array. Because of type erasure, I can't create an instance T[] of a generic array, empty or otherwise. The only way I was able to do it was...
  9. ShayanJ

    Java Asynchronous web programming using Java

    I want to learn web programming with Java. I'm using eclipse neon with tomcat 8.5.13. My question is do these tools support asynchronous programming and server push technologies or should I use other tools? Thanks
  10. N

    C/C++ How Can I Convert Quicksort from Java to C++?

    I have never done Java but my professor says it is similar to c++. I am trying to convert quicksort in java and covert it to c++. I don't know if this is correct or not. Here is the code my professor gave us. .....Java...... public static void quicksort(char[], int left, int right) { int...
  11. N

    Java Recursive Tracing Java: Learn How to Trace a Method

    It would be much appreciated if you could show me how to do recursive tracing for this method.
  12. L

    Java Shopping cart object problems using methods, and arrays no arrayLists. java

    Hello, I cannot seem to get the calculations correct for my shopping cart to print out the tickets and total how many tickets and how much they are. The first set of code is for the shopping cart the comment sections are for what is suppose to be happening in each section. I have the menu...
  13. Kaura

    Java Java Sudoku Solving Program: Debugging Help Needed

    I am attempting to create a Sudoku Solving Program in Java This is what I have to far https://pastebin.com/raw/tgnAGKb2 I have spent close to an hour trying to debug it but to no avail Can someone more skilled than I please point me in the right direction?
  14. sefiroths

    Java Solar system simulator JAVA source code

    Hi, I'm developing a very simple solar system simulator for educational purpose. I had taken from wikipedia mass, velocity of planet and applied universal gravitation formula and applied to all celestial corps. It works well, but when I add the moon... the moon is like a planet, rotating around...
  15. L

    Java What is wrong with my Java array and methods code?

    Hello, I am stuck on this java problem. I was wondering if anyone can figure out what I am doing wrong. Thank you! Problem 1. Given an array of ints, return true if there is a 1 in the array with a 2 somewhere later in the array. ex: has12([1, 3, 2]) → true has12([3, 1, 2]) → true...
  16. Z

    Java 3.15 Program: Text message expander (Java)

    I'm having issues with this code, here are the parameters and results. Create a program using conditional logic and string operations that does the following using your NetBeans IDE and upload it here: (1) Use scnr.nextLine(); to get a line of user input into a string. Output that line. (1...
  17. BiGyElLoWhAt

    Java How do I properly reference images in Java?

    Here's the snippet I'm erroring on. I'm sure I have a bad syntax or I'm not relative referencing correctly or something. Null pointer. xo = new ImageIcon[2][2]; xo[0][0] = new ImageIcon(getClass().getResource("img/x1.png")); xo[0][1] = new...
  18. Z

    Java 3.14.1: Warm up: Text message abbreviation decoder (Java)

    I'm working on this code for my programming class and I'm completely stuck. Here is what I have so far but I keep getting error messages. import java.util.Scanner; public class TextMsgAbbreviation { public static void main(String[] args) { String BFF ="best friends forever"...
  19. E

    Java Some trouble with File I/O [Java]

    I'm trying to write Strings to files in Java. Basically, I'm supposed to read from a file containing text (assumed to be strings). For each line of text, if the String has the format word1 word2 (that is, if it's two words), I have to write it to one file (a list of names), whereas if it...
  20. F

    Java Troubleshooting Java Programming in Netbeans: Tips and Tricks for Beginners

    Hello everyone, I am new to the forum. Programing was never an interest of mine but it’s an unfortunate requirement for classes I am taking I could really some help. I have tried fixing the code the best I can, but when I run this through Netbeans, no matter what numbers I put in for Wall...
  21. E

    Java Recursively sorting an array of strings w/o aux. parameter

    One of my professor's assignments is proving particularly tricky for me. It reads: "Write the method public static void sort(String[] a) that sorts the array a in increasing order. The method must be a short recursive program. Do not use quicksort or merge sort. It should be a lot...
  22. BiGyElLoWhAt

    Java Problem with Java Color (setBackground(Color))

    Everywhere I read, I see I want this.getContentPane.setBackground(Color); This doesn't work for me. It didn't on the last project either, and I just let it slide thinking I'd figure it out. Now here I am, same problem. Any help would be appreciated. Notes: You might get some "errors". Just...
  23. BiGyElLoWhAt

    Java Problem with code, possibly multiple extensions of JFrame

    I am making a simple text editor program. You can load, save and exit, and other things. I have the loading and saving working, but the exiting is giving me a peculiar problem. In my project, I have a gui class that extends JFrame, and I also have an ExitOption class that extnds JFrame. I am...
  24. L

    Java Solving a Java Problem: Countdown Rocket

    Hello, I am stuck on a Java problem in my textbook. Can anyone help me? I have tried many variations to no avail thank you. Question:Write code that prints: userNum ... 2 1 Blastoff! Your code should contain a for loop. Print a newline after each number and after Blastoff!. Ex: userNum = 3...
  25. FritoTaco

    Java Java Applet: Moving Image Object

    Hello, I'm having trouble with moving an object using an image. I want my image "Car" to move left and right when I press one of the JButtons. As you can see, I included a blue rectangle to kind of show you what I mean by "moving". Here is the code for the Blue Rectangle. private int carY =...
  26. S

    Java Java Help with displaying an array list while using other classes

    This is a class assignment that has been puzzling me for a few hours. I need this to print out the values from the passenger array. My code so far prints the values from my aircraft class perfectly but not from my passenger class. Please see my output below: How do I make the output display...
  27. FritoTaco

    Java Troubleshooting Decimal Inputs in Java Applets

    Hello, I am writing a program that takes a users input of how many credits they're taking, and the number of dollars each credit is. The book and parking fee is a constant number (no change). I'm using JOptionPane so users can enter 2 values, 1 for number of credits, and the other for dollars...
  28. D

    Exponential curve fit using Apache Commons Math

    Homework Statement I have the following data which I would like to model using an exponential function of the form y = A + Becx. Using wolfram mathematica, solving for these coefficients was computed easily using the findfit function. I was tasked however to implement this using java and have...
  29. BiGyElLoWhAt

    Java What Issues Am I Facing in Initializing a 2D Array of Objects in Java?

    The code I'm working with import java.io.*; import java.util.*; public class ProgressReport{ File file = new File("grades.txt"); Student[][] student = new Student[1][1]; Student[][] add; int[] scores = {0,0,0,0,0}; String name = ""; public...
  30. BiGyElLoWhAt

    Java Probably very easy question about isNaN() java

    this is throwing me an error while(! isNaN(s.next())) "The method isNaN(String) is undefined for the type ProgressReport" s is a scanner. I'm just trying to tokenize a text doc of the form int String int ... int ... String int ... int int String int ... int ... String int ... int etc. Oh yea...
  31. A

    Comp Sci Keyword search in a hashmap(using retainsAll) in java

    Homework Statement Essentially, I am expected to have a method that can do a keyword search through my hashmap and return respective results. My hashmap is as follows: HashMap<String, Person> phonebook The string as a key is generally the name of the entry. A person object has 3 fields(Name...
  32. DaveC426913

    Java Java Platform: 21st Century Users Deserve Better

    < rant > For ten years I've had a particular program that has only been released in a version to run on Java 6. That's spanned multiple incarnations of Windows, culminating in Win 10. The developers still don't seem to realize what a giant PITA barrier-to-entry Java is. It's ten years later...
  33. A

    Java Java: Finding the numbers in an array above the average

    I am attempting to find the numbers above the average number of a set of numbers in an array. I am having trouble understanding why my output for the list of numbers above the average is so...weird. I'd appreciate the help! My code: public class Inequality { public static void main(String[]...
  34. Y

    HTML/CSS Where Can I Safely Download Java to Open HTML Files?

    Hi I need to download Java to open a certain html. I need suggestion of a safe site to download. There are quite a few when I search and I don't want to click on anyone until I know it's legitimate. Thanks
  35. I

    Java Help with Java Coding: Inputting Integers, Doubles, Characters & Strings

    Hows it going MHB. This is my first post and probably will not be my last. I am not going to come here just asking for answers, but to look for help in my coding adventure. I am currently enrolled into a entry level coding course that kind of just jumps right into things and does give some help...
  36. sukalp

    About computers and being good at coding....

    i wanted to know how to become computer king of world if we have coding talent like making cool apps,software,making technical software machines like robotics. can we become computer king by challenging bill gates like what they did to world we can do in 1 day not by copying but following...
  37. sukalp

    C/C++ Question about learning C++ Linked Lists before Stacks....

    i wanted to ask you that in c++it is important we should learn linked list before learning stack,queue that i wanted to know while studying data structures
  38. A

    Other Taking java learning to the next level

    Hi, I'm currently a Part time CS student that is looking to further advance his java learning. Right now I'm using The University of Helsinki's free CS course to learn java(my own university's course pales in comparison to this resource...) however I'd like to define my path further. I spend...
  39. A

    Comp Sci Simple cardgame project in Java

    Homework Statement Hi, so I'm working on a project(part 1) where I am supposed to create a simple card game, under a few requirements. Here are the requirements: 1. Write a method boolean hasFlush(String hand) that checks whether the five-card poker hand given as 10-character string is a...
  40. A

    Comp Sci Potentially simple java methods HW

    Homework Statement [/B] So my professor has given this as a lab activity. He has not given any sample outputs, other than these simple instructions. I don't actually understand to what extent I'm to perform this activity to. Write a class BankAccount that contains a double field balance, and...
  41. J

    C/C++ Problems with C program- Not C++ and not Java

    A user types a word and a number on a single line. Read them into the provided variables. Then print: word_number. End with newline. Example output if user entered: Amy 5 Amy_5 #include <stdio.h>int main(void) { char userWord[20] = ""; int userNum = 0; /* Your solution goes here */...
  42. O

    Java How can I efficiently replace common text message abbreviations in Java?

    Hi everyone, I've been working on this assignment for a few days now with no luck at all. Would anyone be willing to review this code for me and see if I'm even setting it up right? Here are the directions for the assignment. 1) Use scnr.nextLine(); to get a line of user input into a string...
  43. O

    Java Finding Tree Height Using Simple Geometry and Java Coding

    Simple geometry can compute the height of an object from the object's shadow length and shadow angle using the formula: tan(angleElevation) = treeHeight / shadowLength. Given the shadow length and angle of elevation, compute the tree height. What I have so far: import java.util.Scanner...
  44. O

    Java Reading and printing a string in Java - Assigning values

    A user types a word and a number on a single line. Read them into the provided variables. Then print: word_number. End with newline. Example output if user entered: Amy 5 Result should read as: Amy_5 import java.util.Scanner; public class SpaceReplace { public static void main (String []...
  45. O

    Java Acceleration of Gravity in Java

    Compute the acceleration of gravity for a given distance from the Earth's center, distCenter, assigning the result to accelGravity. The expression for the acceleration of gravity is: (G * M) / (d2), where G is the gravitational constant 6.673 x 10-11, M is the mass of the Earth 5.98 x 1024 (in...
  46. user123897

    Java Numerical integration of an harmonic oscillator using java

    Hi, I am trying to analyze the an harmonic oscillator using kinematics. first i calculate the force applied by the spring (f = (-x)*k) then i calculate the acceleration (a = f/m) then speed (v= v0 + v0t + 0.5*a*t^2) and finally update x (x = x0+vt) this is a simplfied loop of my program...
  47. S

    Java Trouble with Buffered Reader and Exceptions in Java?

    Hello mathhelpboards community! I can't figure out how to get my code to execute while using buffered reader and try with resources. :-( I created a data.txt file correctly and it contains the numbers "0.5 3 10 70 90 80 20" without quotes. I added a catch IO Exception utilizing the...
  48. S

    Java Java- Printing an Original Array while Performing Operations on an Array Copy

    Hello mathhelpboards community! Please help! Thank you. :-) I need my code to print out the user's original array that is to say the numbers in the way the user entered them. I tried making a copy of the original array and then did all of the arithmetic on it. I sorted the array copy in...
  49. Z

    Java How to add elements in a Java swing List Box

    Hi, I am using NetBeans 8.1. I want to add elements in a list Box on a Button press. My code would read text from textField & then insert into list box: private void button1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your...
  50. E

    Java What are the differences between creating graphical programs in Java and C#?

    A https://driven2services.com/staging/mh/index.php?threads/18929/ about Java prompted me to ask about graphics in Java and C#, especially from the standpoint of teaching. I know how to create graphical applications in Java using Swing, but I know very little about C#. Swing applications have a...
Back
Top