Java Definition and 587 Threads

  1. S

    Java Can I assign probabilities to events in Java?

    Hello. So I'm wondering if there is a way to assign a probability to a certain event in the code. Let's say that I want a certain arithmetic operation to have an 80% chance of happening (and make an if/else if statement based on that, or something similar...) Is there something in the...
  2. Y

    Java Can someone help with my Java installation issue?

    I have been trying to install Java and failed. After installation completed and close the installation window, an error message popped up saying: "Wrapper.CreateFile failed with error 5: access denied." The java don't work. I tried reinstalled a few times and still failed. Please help...
  3. R

    Java How to create a box around text in Java. Inside windows cmd.exe

    How can I make a box around text in Java which will appear in Windows cmd.exe? Only using System.out.print("X"); and System.out.println("X"); . It MUST be a solid box and not use symbols like - or _ . It can also use int X , double X, char X, String X, and boolean X. Please explain...
  4. S

    Java Learning Java Web Services: Books & Order to Read for Data Gathering

    I have an urgent need to learn to gather data using web services in java. I've picked up several books which all seem over my head. Can anyone recommend a stack of books and tell me what order to read them in? Otherwise if anyone can at least tell me what order I should tackle the necessary...
  5. stripes

    Comp Sci Turning a Java program into an applet

    Homework Statement Very simple: I want to allow my existing Java program to run in a browser. Very simple. I don't want to change any code around, I just want to open it in a browser instead. I have read many tutorials online, and they require that I add weird methods like destroy, init...
  6. Y

    Java [Java] How do I save a bunch of images as one?

    I have a program where the user selects image icons in one JPanel and can place them in another JPanel. The program saves the position of the icons as an array of integers where each integer represents the different icons. I need to also save the final result as a .gif image because otherwise it...
  7. S

    Java Java Applet Issues: Solve NoSuchMethodError

    Hello, I am currently enrolled in an introductory Computer Science course, and I've been having trouble with a Java/HTML project. I have been given the following code for a triangle applet to be linked in an HTML page I have to make: import java.awt.*; import java.applet.Applet; public...
  8. G

    Comp Sci JAVA CODING - Implementing methods for a game, API

    import acm.graphics.*; import acm.program.*; import java.awt.Color; import java.util.Iterator; import java.util.Random; import java.util.List; public class LAB1 { final static int BLOCKWIDTH = 50; final static int BLOCKHEIGHT = 10; final static int NBLOCKS = 10; final static...
  9. Whovian

    Java How does java know what class to invoke the main() method of?

    In C++, pretty much any global main() function gets run. In C#, amy class's Main() method gets run, and having multiple Main() methods in multiple classes should give a compilation error(?). But if we have a .jar, when running it, how do we know which class's main() method the .jar will run?
  10. R

    Java Java Exception - NoDefClassFoundError

    I'm trying to run a java program I coded using geany but it would let me run it as it comes up with the following error message. Exception in thread "main" java.lang.NoClassDefFoundError: temp Caused by: java.lang.ClassNotFoundException: temp at...
  11. X

    Java Fix Java Linked List Output Issue & Error

    Can someone tell me why there's no output? I compiled it, and it should work, but there's simply no output (netbeans). It also says "incorrect package" at the top of every file. It's a linked list that adds cars, sorts them, and (should) display the sorted results. There's also an error in...
  12. X

    Java Java. Searching and sorting a stack

    I'm trying a practice problem from the book. It's 10 books with title, ISBN, and year. The input needs to be sorted by year and it needs to let you search for a book title. class LinkedStack { /** The Node class is used to implement the linked list. */...
  13. A

    Java Java software for solving linear systems

    Hi, I made this program in java, take a look: https://github.com/BetoKahn/Gauss For the english version I didn't uploaded the code, only the runnable .jar file. For the portuguese speakers you can see the code. I hope you enjoy,
  14. sankalpmittal

    Comp Sci Need Help with Java Program: Uppercase & Lowercase Conversion

    My teacher gave me a program in Java which none of us were able to do. So, I need help. Homework Statement We have to find the uppercase of the lowercase alphabets which the user inputs and vice versa. In case the character is special character, then it will leave blank space. It will work...
  15. A

    Java Finding Java Learning Resources: Where to Start?

    A coworker asked me if I had any recommendations for Java learning resources; I thought about it and really didn't have many since my programming life has been an odd mixture of Python, Fortran, and C++. And this got me wondering, does anyone have any good suggestions for Java learning resources...
  16. M

    Java Good books/articles I can learn java from? Or another programming language?

    From free PDF's to books I have to buy. Anything that will be helpful
  17. C

    Comp Sci JAVA classes/constructors question

    Homework Statement I just have a quick question and hope I can ask it clearly. If I am writing a constructor for a class that takes in one value as an argument, but the value is two words, how can I extract the first and second word? For example, if I wrote a class called Name and my...
  18. W

    Java How does the 'amount' parameter in the recordPurchase method work?

    I'm having trouble with understanding how methods that have a parameter work. For example, public class Register { private double purchase; private double payment; public static final double QUARTER_VALUE = 0.25; public static final double DIME_VALUE = 0.1; public static final...
  19. S

    Comp Sci Java - Postfix Notation Expression Evaluator

    Homework Statement I need to write a program that evaluates a postfix notation expression using a stack. Homework Equations 5 3 2 * + 4 - 5 + = 12 The Attempt at a Solution /* * To change this template, choose Tools | Templates * and open the template in the editor. */...
  20. N

    C/C++ C++, java, or python programming

    i know this topic has been discussed, but i would really want a direct reply and soon Do i have to learn java or c++ in order for me to learn how to be a hacker?... good intentions off course, for security and privacy needs... please let me know. Thank you.
  21. S

    Comp Sci Getting ArrayOutOfBoundsException - java

    Homework Statement I am supposed to write a program that has the user enter 10 nouns and 10 verbs. It then creates a 4 sentence story using the those words. I am getting an ArrayOutOfBoundsException when it gets to the part where it prints out the story. The exception is found in the grab()...
  22. C

    Comp Sci How Should I Implement the UserID and Password Generation in Java?

    Homework Statement This is my assignment: (Sorry, it's a little long) You are required to write a UserID Java class to be used when generating and storing the user id and password for a new user of a system. At a minimum, each UserID object should store a first name, last name, user id, and...
  23. L

    Java Java: create a dictionary/ vocab list

    Is there a way I can get the definitions from, say, dictionary.com? Does much method already exist or do I have to go about creating one? How would I get a specific something from a specific website? I prefer using java, but if there's another language that makes it easier, I also know C++...
  24. S

    Comp Sci Why Does My Java Program Display the Menu Before Adding or Removing Items?

    Homework Statement I am supposed to write a program that uses a bag of strings to keep track of a list of chores. The user can add, remove, view, etc. items on the list. Homework Equations When I run the program and i choose an option from the menu. It displays the menu again before...
  25. B

    Java What's Causing the Do-While Loop to Fail in JAVA Program?

    I don't know why in the main method, the do-while loop won't work the way it's supposed to. For instance, if the user types in y, the first loop would execute and then since the value of choice is still 'y', it's supposed to loop again. But instead, it just displays "TOSS COIN? Press y for...
  26. G

    Comp Sci Java Class Arrays: ArrayTest Method

    Homework Statement Create a Java class named ArrayTest with a method called arrayCombiner that creates three arrays of size 10. The first array should contain the values 1, 3, 5, 7, 9, 11, 13, 15, 17, and 19. The second array should contain the values 2, 4, 6, 8, 10, 12, 14, 16, 18, and 20...
  27. S

    Comp Sci Java - bag adt with linked list

    Homework Statement "Implement a new method for the bag class. The new method allows you to subtract the contents of one bag from another. For example, suppose x has seven copies of the number 3 and y has two copies of the number 3. Then after activating x.subtract(y), the bag x will have...
  28. S

    Comp Sci Linked list sorting method in java

    Homework Statement I need to write a sorting method for my IntNode class. this is supposed to use the selection sort algorithm. Homework Equations selection sort algorithm given by problem while(the first list still has some nodes { 1. find the node with the largest element of...
  29. M

    C/C++ Java or C++ for Robot programmeng?

    Hi everyone! I am a mobile robot designer in autonomous space robotics. there is a great dilemma in front of me to opt a programming language for the robots between C++ and Java. the most important factor for me is performance of the language when i want to use it for applying very...
  30. A

    Java Java program to communicate with a USB port

    Hi, I want to write a java program to get information from a USB communications port. I have downloaded the javax-usb-r1 package but I don't know where I should place this folder / package. Can anyone give some advice? Thanks
  31. P

    Comp Sci Java Word Counter: Define Method & HashMap Return

    Homework Statement I have to define part of a method that will take in a String, segment the input into words, keep track of how many of each word there are in the string, and then return a HashMap<String, Integer> that shows how many of each word there are in the string. A separate helper...
  32. A

    Java Exploring the Advantages of Java for Android Development

    The Android system is an OS by java for java, but why? What significant advantage does java posses over other languages? Is it because high-end hardware are so cheap and numerous, that no one need to think about the runtime efficiency anymore? Or because google want to make money, and somehow...
  33. S

    Comp Sci Data Structures & Algorithms in JAVA: Graphics using JFrame

    Homework Statement This assignment handles topics of events and GUI-elements. It's a little game. The task: create a window with a button that randomly relocates to a different position on the screen each time it is hit. The player has to hit the button 10 times, the score is the time needed...
  34. K

    Java Java hasNext, Ctrl-Z not working

    I am using Windows 7, netbeans 7.0.1 and the latest Java package I am writing a simple while loop with hasNext() method as its condition, and supposedly the end-of-input indicator for Windows is Ctrl+Z, but that does not work for me. I also tried Ctrl-d, which supposedly works for Macs, unix...
  35. E

    Comp Sci Magic Square Java Homework: Implement Class Square

    Homework Statement An n by n matrix that is filled with the numbers 1, 2, 3, … n2 is a magic square if the sum of the elements in each row, in each column, and in the two diagonals is the same value. Write a class that creates a square matrix (as a two-dimensional array) andtests whether...
  36. M

    Java Opengl and java - jogl installation

    i'm trying to learn opengl with java (jogl binding), but there is no way i can set up things to work appropiately. I've spent hours trying to find the right files to download, and put them in the right folders and set the 'path' variables and so on.... but i couldn't get a success in hours, it's...
  37. R

    Java Good Java IDE with code complete?

    I've been learning C# but just want to give Java a go before I start learning the difficult bits of C# to see which I prefer, most people say the 2 languages are very similar but I just wanted to see for myself. I really like having a code complete function in the IDE but I tried Netbeans but...
  38. O

    Java Understanding Java's Math.abs() Method: Solving the Minimum Integer Value Issue

    When you take the absolute value of an integer value: http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Math.html#abs(int) Wondering if anyone can explain what abs does that makes it fail on the minimum integer value
  39. R

    Java Why Does My Java Bouncy Ball Not Behave as Expected?

    I'm having a bit of a problem with physics calculation for a bouncy ball program I am creating in java. I've been java programming for almost three years, and excelled in my class, but when it comes to physics for java games and what not, I am totally useless. Heres the problem: a Ball, when put...
  40. M

    Java Optimizing Graphics Acceleration in Java: A Solution to Slow Mouse Motion Update

    I have made a java code which displays a blue sphere and let's you control with the mouse where its illumination comes from. (its actually a circle and some parts are painted white/blue/black depending on the mouse position to make it look 3D) here is the code import javax.swing.*...
  41. pairofstrings

    Java Method called Math.random() in Java

    Hello everyone. I am investigating this method and trying to find how random numbers are getting generated. Please look at the following code. class RandomNumbers{ public static void main(String[] args) throws InterruptedException{ int count=0; while(true){ double d = Math.random()...
  42. pairofstrings

    Java C and Java questions that I asked my teacher

    My teacher says : C language programs are portable on all platforms, which includes, Unix, Linux, windows etc. My question : What is the difference between C language programs and Java language programs when all the programs of either languages can be run on any platforms? My teacher says: C...
  43. A

    Java JAVA how to get rgb values from an image

    hello, i'm kinda new in this programming thingy so i hope you guys can help me. i wanted to code a program that can identify whether a banana is ripe or not. basically, i have two image of banana; one yellow in color and another one is green. so I'm thinking about using AI technique...
  44. pairofstrings

    Java Do we have a concept(?) called 'Hashfunction' in 'Hashtable' in Java?

    I know what Hashtable is. I have seen the methods that it contains and used these methods. I know the differences between the implementation classes. But I have not come across anything called 'Hashfunction' during the time when I was studying Collections framework. Is this 'Hashfuntion' has...
  45. X

    Comp Sci How do I fix this Java NullPointerException?

    Homework Statement There are three classes: import java.math.BigDecimal; import java.util.Date; import javax.swing.JOptionPane; public class CreateTicketList { private ArrayObj aObj; public CreateTicketList() { aObj = new ArrayObj(new Ticket(), 100); } public void...
  46. Z

    Comp Sci How to Capitalize the First Word After Reordering in Java?

    Like this is my program to change the words around in order. Like First two words go to the back. What I am having trouble is, How do I capitalize the first at the results section after the words order have changed?? This is my program. import java.util. Scanner; public class...
  47. D

    Comp Sci Help with Java program calculation

    Question: Write a program to convert 22 square metres into square kilometres. Note: divide square metres by 1 million to produce square kilometres. Note also that the answer is not zero! I know the note says the answer is not zero but shouldn't it have some value other than 0 ? My code...
  48. T

    Comp Sci Java Error: The operator > is undefined for the argument type(s) E, E

    Hello. The method here is to add an item to a heap. As the title states, I am getting the error "The operator > is undefined for the argument type(s) E, E" in the parenthesis after the while. I assume this is not the correct way to compare E values. Does anybody know what would be the correct...
  49. A

    Comp Sci Java Maze Boundary Check Method for Pathfinding

    I'm writing a method that checks a given coordinates neighbors to see if they are part of the path. the problem I am having with is the conditions that ihave to make sure i don't go outside of the grid. it doesn't seem that the two conditions for col are being checked. i put print statements...
Back
Top