Java Definition and 587 Threads

  1. D

    Can I put radio buttons above an ImageView in a ScrollView?

    Hi everyone I'd like to set an ImageView background for a menu screen that uses ScrollView, ConstrainedLayout and Radio Buttons. This is possible if I hardcode the width and height of the ImageView, but I don't want to do this because it might ruin the formatting on some models of phone. I'd...
  2. D

    Why does my game loop give me a blank screen?

    Hi everyone I've used a game loop to try make a textView alternate between two different strings every two seconds. When I run it, I just get a blank screen. The textView was originally set to show "Hello World!" but not even that shows. Does anyone know what's gone wrong? Thanks public...
  3. D

    Java How do I prevent threads from interfering with each other in Java?

    Hi everyone I'm making a Whack-a-mole-style game for learning katakana. I have a textView for the question, a textView for the answer and nine buttons. I have a SetQuestion runnable to show the question and answer. Each button has its own runnable that controls how long the button flashes...
  4. T

    Java Indexing Problem with Java Program: ArrayIndexOutOfBounds Exception

    I encounter this issue when trying to make this program in Java. My first input is a number n to indicate how many lines of input for Java to expect next. For each of my next n lines of input, it is in this format 'name value', e.g 'bolt 9.58'. Then for each line, I want java to append the name...
  5. G

    Java Please help explain the reason for the errors displayed for my Java code

    //program showing an advantage of using arrays public class Arr3 { public static void main(String []args) { System.out.println("There are 31 days in the month of Jan"); System.out.println("There are 27 days in the month of Feb"); System.out.println("There...
  6. G

    Java Why Is My Java Program Not Working?

    Please help me to find what my mistakes are in the following java program.
  7. D

    Java Recursion with a Runnable in java

    Hi everyone Could someone show my the correct way to use a recursive runnable? The example I have involves the invokeLater method from SwingUtilities. public void mousePressed( MouseEvent e ) { Runnable runnable = new Runnable( ) { public void run( ) {...
  8. D

    Java How do I get Java to perform an action so long as a button is pressed?

    Hi everyone I got the code below from YouTuber, Bro Code. It prints "Hello" every time you click on the button. I wanted the button to print "Hello" while it was held down and stop printing as soon as the button was released, so I changed this line if(e.getSource()==button) to...
  9. Astronuc

    Java Mag 5.6 earthquake - Java, Indonesia

    https://earthquake.usgs.gov/earthquakes/eventpage/us7000ir9t/executive M 5.6 - 18 km WSW of Ciranjang-hilir, Indonesia 2022-11-21 06:21:10 (UTC) 6.853°S 107.095°E 10.0 km depth - relatively shallow https://earthquake.usgs.gov/earthquakes/eventpage/us7000ir9t/region-info City of Cianjur had...
  10. Margarita0076

    Engineering HL Programming: Mini-Assembler in Java

    I already wrote the regToByte method, but I don't understand how to write the makeI and makeR methods correctly. Create a mini-Assembler for a 32-bit MIPS processor; Program should accept input lines from the user until HALT is read. With each line, translate the line into MIPS machine code...
  11. D

    Computer Science Help C# or Java

    I succeded to do the first method, but I could not do the second one. The first method: public static Node<int> Delete(Node<int> lst, int num) { Node<int> p = lst.GetNext(); for (int i = 1; i < num; i++) { p = p.GetNext()...
  12. D

    A question about lists in C# or Java :)

    I could not understand the question, I have really tried to solve it but I could not. I will appreciate any direction to the solution. Thanks in advance:)
  13. A

    Java Error in Installing javac for fedora 20 and java version 1.6

    By default, I had Java 7 installed on my system(X64, Fedora 20). I needed Java 6 for a software, hence had to remove 7 sudo yum remove *java* And then, I installed Java 6. This installs Java 6 successfully. but the java compiler, JavaC is missing. For that, I try - su -c "yum install...
  14. WMDhamnekar

    Java Java with Ant in Apache Netbeans IDE 12.4

    I am the beginner in learning to write Java programming commands. In the attached picture the output didn't show my name and surname. I don't understand what was wrong? Would anyone explain here?
  15. Ghost Quartz

    Java Why is the do-while loop in my Java code printing '9'?

    int bd= 15; int ad= 5; while(ad!=9){ System.out.println(bd); ad++; bd++; }//output 15,16,17,18 do { System.out.println(ad); ad++; }while(ad<=9);//output 5,6,7,8 thanks for the help
  16. I

    Comp Sci Matrix problem in java using bubble sort

    I have taken the variables as follows: A[][]=the matrix max=to store the maximum integer value present in the matrix min=to store the minimum integer value present in the matrix sum=to store the sum of boundary elements display()=methos to print matrix sort()=method to sort matrix in descending...
  17. Wrichik Basu

    Java Searching & Displaying Items in Android App Using Java & SQL

    This is actually for my new Android app. But everything is written in Java and SQL; there is almost nothing that is specific to Android. I have a database, and the following three tables are of interest here: itemEntity with columns: itemID: integer primary key itemName: String; indexed to be...
  18. A

    Comp Sci JButton in JPanel with gridlayout

    Is it possible to bring it into this shape using the gridlayout? I use empty label to add this empty gridThis is my code:import javax.swing.*; import java.awt.*; public class test { public static void main(String[] args) { JFrame frame = new JFrame()...
  19. V

    Comp Sci Programming with Java -- Reading From the Terminal

    Right now I am learning coding on Java using IntelliJ IDEA. I have coded before on C++ and then Python, so I understand a little on Java. I'm not really sure how exactly I would change code so that it would read input from the terminal? Would I have to use a Scanner for this? I can post the...
  20. I

    Learning Data Structures in Java: Circular Queue

    Summary:: I have recently started with data structures in java and I tried doing this Program .But I have few confusions. 1.How do I write the main() of the program? 2.What are we supposed to do with the value returned by function pop()? If anyone could point out if there are any errors and...
  21. P

    Comp Sci Answer: Fixing Error in TextAnalyzer Java Code

    My current attemp is: import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class TextAnalyzer { private int lineCount; private int wordCount; private int[] frequencies = new int[26]; public int...
  22. A

    Comp Sci Problem with this Java string program

    Summary:: I'm having problem with this source code.we need to find the frequency of the number of words beginning with an UPPERCASE Alphabet in a sentence. The data members and member method must be according to the question given in the document. though i could compile it but it's giving...
  23. A

    Comp Sci How to Structure Java String Code in a Static Main Method?

    here the class name is test153 sent is the sentence entered l is the length of the sentence w is the variable storing each word temporarily before printing.
  24. A

    Java Main() method in java - pre defined or user defined?

    although we cannot change the syntax of the main() method but programmer does create main() everytime in the program.so i want to ask if it should be pre defined method.
  25. D

    Java Java Tree Map always gets initialised but shouldn't, why is that?

    here is the portion of code [Code tags added by the Mentors] public void addPosition(String name, String skillNames) throws ApplicationException { Position ps=new Position (name); //creating object position if(listaPosizioni.get(name)==null) { //checking if position already present...
  26. T

    Java Should I enroll in a python course or java? (I’m studying physics)

    Python based course or java course ?. I will be taking an introductory computer programming course . One is python based and the other is java based. The java based course has 2 semesters and goes more in depth with programming . Would it be useful to just take the java courses and get the...
  27. J

    Comp Sci Java - Why no out of bounds error for this array

    I am writing a class called "Course" in Java so that one can input students names, etc. Here is my relevant code for the Course class: public class Course { private String courseName; private String[] students = new String[0]; private int numberOfStudents = 0; public...
  28. T

    Java Changing the Universal Gravitational Constant: A Java Applet

    Hello folks, I am working on Java program just for fun to model an n-body problem using 3-dimension graphics. I'm looking for a way to speed up the model. Suppose for example that I decide to increase the speeds of all objects by a factor of, say, 2. To compensate, I would also increase the...
  29. J

    Comp Sci Modeling the queues at a college restaurant

    So far, I have implemented the code below, using Java Priority Queues and Maps. I tried to identify each customer by the time they came in (ranging from 360 and onwards) and their grades. However, this is my first time using priority queues and maps, and I am not very sure if I'm doing things...
  30. J

    Comp Sci Twitter API finding the most common word in a tweet

    So in the class TJTwitter, I have the following defined: private Twitter twitter; private PrintStream consolePrint; private List<Status> statuses; private List<String> terms; private String popularWord; private int frequencyMax; and in the same class, I have a few methods that are meant to...
  31. A

    Java Java 'if' Statements: Solved & Explained

    Edit: Never mind guys, figured it out. I needed to use s.equals :) However, could someone explain to me why we can't use == on a technical level? I'm curious to know on a technical level. Hi guys Doing a bit of programming, and I'm not too sure why I'm not getting the expected results. Below...
  32. Wrichik Basu

    Java Newer versions of JDK have a "private" JRE?

    I had JDK 12.0.1 for some time and recently upgraded to JDK 13.0.1. During the installation, this screen was shown: I know that newer versions of JDK have no accompanying separate JRE; the standalone JRE currently available is 1.8.0u231. But what is the story about this "private" JRE? How to...
  33. Avatrin

    Java ML infrastructure with Pyspark for Java backend

    Lets say I have experience creating ML models in Python, and have decided on training my models on Spark using Pyspark. This will form part of an ML infrastructure for a website with a Java or C# backend. How can I make this work? I am a beginner when it comes to Spark. I am looking for any...
  34. T

    Java Run Java Applet on Website: Troubleshooting Guide

    I'm trying to run this java applet on this website: http://astro.u-strasbg.fr/%7Ekoppen/discharge/discharge.html But the security settings in java doesn't allow it. I have added the website as exception in the java control panel, but it is still being blocked. How to run this java applet?
  35. R

    Example illustraing Quantum programming

    I'm interested in quantum programming. So far I've managed to use Java and Python inside Datamelt computation project for physics simulations and for various statistical plots. Now I want to make a simple code that illustates quantum computing, and maybe even to visualize its principles (for...
  36. Z

    Java Can't Traverse a Doubly Linked List in Java

    Hi, I can't traverse the doubly linked list. My code is:class Student{ int id; String name; Student next, prev; Student(int id, String name){ this.id = id; this.name = name; next = null; prev = null; } } public class DLLAddtoTail { Student head =null...
  37. hagopbul

    Java Why is this Java code not working?

    Hello all: I am reading a comutacomputa physics book and trying a code from it in MATLAB it is not working and due to my lack of knowledge in this field I can't see where is the mistake hope you can take a look import java.lang .*; public class Motion { static final int n = 100000, j =...
  38. O

    Java I about how to get a pixel value in Java

    Greetings! Hey guys, I need help on how can I get pixel value of an image with pixels more than 100px (10x10). Here the code that I execute in order to get the pixel value try{ File f = new File ("input image location"); BufferedImage img = ImageIO.read(f)...
  39. I

    Comp Sci Why Is My Java Monte Carlo Simulation Not Approximating Pi Accurately?

    Homework Statement There is a square and a circle is inscribed inside. Simulate an experiment where raindrops drop on this surface. Some raindrops can drop in or on the border of the circle. Some can drop outside the circle. The area of the square divided by the area of the circle gives you pi...
  40. S

    Java Updating an index variable in Java

    For the life of me, I can't figure out why my program won't update the index variable. I've tried setting the index to 0, and then to -1, and to the size of the arrayList - 1. I'm trying to use the index to get the previous and next flashCard in the arrayList to show up. I have been working on...
  41. S

    Java Java- How to allow access to a different GUI menu for Learner and Admin

    I am trying to get two different menus to show up depending on whether the User is a learner or an admin. However, I'm having some difficulty with the program and the execution. I would appreciate any help or suggestions. I don't know how to access a user to figure out if it's a learner or an...
  42. Z

    Java .xlsx Excel files in Java: Sheet & Workbook error

    Hi, I am trying to access Excel Sheet .xlsx files in Java. I have tried various options available from internet. My program is using following jar files: poi-ooxml-3.5-beta4.jar, openxml4j-1.0-beta.jar I have done following imports: import java.io.*; import java.io.File; //import...
  43. Wrichik Basu

    Java Preferring Scanner to BufferedReader for taking input

    I have seen that in many cases, teachers and authors prefer Scanner to BufferedReader for taking input from the user through keyboard. I have found two reasons for this: 1. Scanner class manages exceptions implicitly, while for BufferedReader, exceptions have to be handled either by try..catch...
  44. Peter Alexander

    Java Android Studio: Accessing SQLite Data In RecyclerView

    Hello everyone! I'm working on a simple app for a project at the university and I'm having problems accessing the SQLite data in RecyclerView. I suspect that the problem lays in a connection with an activity that includes the RecyclerView and the RecyclerView adapter itself. My project, in the...
  45. W

    Java Java: Which Term determines this is a Sum?

    Hi all, I have the code below with a 'for' loop. I see the output is 17, the sum of all elements of the (variable?) result. I am a bit confused: I cannot tell which part of the code is used to determine that the values {1,2,10,4,5} must be added to each other? Please comment/correct: 1)We define...
  46. W

    Java What are the top IDEs for Java Database Development?

    Hi All, Teaching myself Java programming from 0. I used some online forums. Now I would like to work, programming on my own PC, i.e., not just as a client . What are good IDEs for Database Dev work? I have been recommended Atom .
  47. QuantumQuest

    Java Exploring Java 9 & 10 Features: JDK 9.0.1 & Beyond

    It is about five months since Java 9 was released (JDK 9.0.1 October 17, 2017) and while developers and other users of Java try to keep up to pace with its new features - while others are just adopting Java 8, Java 10 is out! So, I thought that it would be useful for anyone developing / using /...
  48. S

    Java Java- CompareTo with Binary Search Tree

    I am having a hard time implementing comparing a given String name with the names of the Dog objects in my binary Search Tree. The problem comes from my containsRecursive() method. I need to use a String name to find if the name is already in my Binary Search Tree.Here's what I've tried...
  49. D

    Java What should i study in order to build my first Android app?

    This year I made a resolution to by the end of summer build an Android app for my Uncle’s bussiness (Rent-a-Car) which would help him organise the dates of booking a car. I have previous programming experience with C and C++ but not with app creating. The idea for the app is really simple but...
Back
Top