Java Definition and 587 Threads

  1. estro

    Java Java [String a = new test ] vs [String b = test ]

    Java [String a = new "test"] vs [String b = "test"] Can you tell me what is the difference between the two? What is going on behind the scenes?
  2. S

    Comp Sci Troubleshooting a Polynomial Function in Java

    Homework Statement We must make a class used to evaluate a polynomial function of x. My problem is I am getting an array out of bounds exception when I run the main, and I can't figure out why. If you could help me figure out this out of bounds exception it would be very appreciated thank you...
  3. H

    Comp Sci Counting Words and Characters in a Text File: A Java Program

    Homework Statement Write a program that takes a file name as argument and counts the number of words and the number of characters (without spaces) in the document. Homework Equations The Attempt at a Solution How exactly should my program take a .txt file as an argument? Do I simply: String...
  4. stripes

    Comp Sci Fixing Java Compiler Error: ';' Expected

    Homework Statement So I'm trying to create a method in java. The method is supposed to take a string and use the rot13 method to hide the message. That is, it takes each letter and places it forward 13 letters, so a becomes n, b becomes o, etc. Now I'm pretty sure this method is at least...
  5. P

    Comp Sci Java 15 Puzzle Homework: Setup Visual Part & Restrictions

    Homework Statement My class is required to write the Java source code for a 15 Puzzle program as an end of the year assignment. http://en.wikipedia.org/wiki/15_puzzle" is a link to what the 15 Puzzle is, for those who aren't familiar with its name. The assignment is split into two parts...
  6. Z

    Java A Guide to Programming in Java by Lawerenceville Press exercises?

    A Guide to Programming in Java by Lawerenceville Press exercises?? KK Nevermind.
  7. N

    Comp Sci Weird File Output behavior in java

    Homework Statement I've implemented RSA and just need to print some stats and write to files.Homework Equations My solution works fine when I provide an input file, however, if I let it read from standard input there is no output written to either of my output files. Reading works regardless. I...
  8. H

    Comp Sci Caesar Java Program: Writing Code & Decrypting Messages

    Homework Statement Homework Equations The Attempt at a Solution public class Caesar { public static void main(String[] args) { int k = Integer.parseInt(args[0]); char c; String strMsg = StdIn.readString(); System.out.print("Encrypted sentence is: " ); for (int i = 0; i <...
  9. G

    C++ or Java for Undergraduate Research Oppurtunities?

    Hello, everyone. I've been learning how to code for a bit. I picked Python because I figured I'd be able to skip the issues I would otherwise have with syntax and focus more on the programming aspect of it. Soon, though, I'm going to be ready to dive into one of the other languages with a...
  10. A

    Java Simple Java Grade Program - Calculating Exam Scores and Grades

    Hi i am looking for following output.so far I am only getting result for total no of grades.I am getting 0 for A B C D and F.
  11. B

    Comp Sci Java - Solving a problem, getting an error

    Hey guys, there is this problem from my school in which I'm having troubles.. This code is from past school lab (assignment) assigned a loong time ago And I figured I would go back to it, to practice my coding skill, since I wasn't able to solve it back then. So here is the code...
  12. L

    Java Why Does This Java Code Only Store One Answer in an Array?

    hey - any idea why the following bit of code only stores one of my answers, and not both in an array like i was hoping? thanks 1 /* 2 * To change this template, choose Tools | Templates 3 * and open the template in the editor. 4 */ 5 package gose1b; 6 7 import...
  13. K

    Comp Sci Help with string.matches() in java

    I have input from the user which is the last name, sent to be set as the last name for my object in my setLasttName method. public void setLastName(String lName) throws IllegalArgumentException { if (lName.matches("[a-zA-z'-]")) { this.lastName = lName; } else {...
  14. A

    Comp Sci Java Stack Calculator | RPN Conversion Help for Beginners

    First i create simple claculator.but now I am trying to change it to RPN calculator by using stack.Can some one help me((especially where to use pop method) because I don't know a lot about stack.here is my codes so far. import java.awt.event.*; import javax.swing.*; import...
  15. L

    Java JAVA - composition/aggregation confusion

    im a bit confused - please help - I am a complete beginner! I have several classes, within which are several attributes defined and declared. The assocation between some of these classes are aggregation, and between others is compostion. Take the example of person and car being and...
  16. stripes

    Comp Sci Declaring an array in a for loop (Java) or similar

    Homework Statement I need to create a loop that asks the user to input double numbers into an array. The number of elements in the array is not predefined; the user will continue to enter numbers as long as they wish until a NEGATIVE number is entered, at which point the control will exit...
  17. H

    Comp Sci Check if a String is Palindrome with Java Program | Homework Statement

    Homework Statement Write a method isPalindrome that accepts a string as argument and returns true or false indicating if the string is a palindrome or not. A palindrome is string that can be read the same way forward and backward. Your method must handle upper and lower case characters (the...
  18. Y

    Java Need help dealing with keyboard listener in java

    I have a program which uses a keyboard listener and moves a character in the program when the user places a key. However when the user let's go of the key the character keeps going a few more steps. I think what is happening is that I use a while loop and make it wait a few seconds in order to...
  19. A

    Java I with this java program that has to use do while loop?

    here is import java.util.*; public class oddNumbers { public static void main(String[] args){ System.out.println("enter two number"); Scanner kb=new Scanner(System .in); int number=kb.nextInt(); int number2=kb.nextInt(); int s=number2/2; String decision...
  20. B

    Java Sample code/tutorial for simple, educational, physics java applets?

    Something like this: http://www.falstad.com/vector/ Particularly concerned with particle motions. I don't know how to begin with using physics equations for creating simple java visual simulations. Can be 2D or 3D. I know some java programming so I'd prefer code examples than...
  21. A

    Comp Sci How can I efficiently find the closest leaf in a Java Binary Search Tree?

    Im having trouble with a method that finds the height of the closest leaf. What i have just counts all of the leafs. would i have to separate the recursive calls into two conditional statements to check each one independently? any help or suggestions would be appreciated this is my method...
  22. H

    Comp Sci Java infinite loop (problem statement)

    Homework Statement http://pastebin.com/7ehbwkvE expires in 1 month... the problem statement is very vague... we are given this code of an infinite loop, and need to fix the problem that it poses by either using a correct while loop or a for loop. Homework Equations The Attempt at a...
  23. M

    Java What could be causing my Eclipse program to reference a non-existent Karel file?

    "Hello World" Java issue! I've been following Stanford's on line lecture series Programming Methodology and have run into an issue while trying my first Hello World program. I'm using the Eclipse editor and have attached the acm JAR library. When I try to run the file, I get an error that...
  24. S

    Java How to Check Equality Between Fahrenheit and Celsius Objects in Java?

    I'm having to create a temperature class for one of my assignments, were just getting into oop. Basically we just create a few constructors, accessor and mutator methods. The mutator methods are where celsius-farenheit conversions are. And we need to make an equals method which I know how to do...
  25. B

    Comp Sci JAVA PROGRAMING QUESTION, Hotel Reservation Sysytem

    System Requirements: Congratulations! Your software company BestSolutions Ltd has won the contract to develop a new hotel reservation system for the L4 chain of hotels (check out l4hotels.com! ...or something similar). At present the chain consists of a 5-star, 4-star and 3-star hotel but the...
  26. P

    Comp Sci Stop Input with Control Z: Java Loop

    I am having the user enter a bunch of strings and when the user wants to stop entering them I want him to use control z to stop the input. The only problem is I can't seem to figure how to make that happen, does anyone have any suggestions?
  27. B

    Comp Sci Java JOptionPane and accepting characters as input

    I am writing a program using JOptionPane that asks the user to input a decimal number, and then outputs the decimal number in binary. The program then asks the user if they would like to convert another decimal to enter y/n (with case being irrelevant). I was able to ask the user for the decimal...
  28. H

    Comp Sci How can you print all the powers of two up to a given number in Java?

    Homework Statement Write a program that takes a command line argument integer M and prints all the positive integers that are powers of 2 and less than or equal to M. Homework Equations for loops; if conditional. The Attempt at a Solution public class PowersOfTwo { public...
  29. P

    Java Java - Accessor/Mutator Methods and when you need a return type specification

    We learned of accessor and mutator methods in class recently. But even after a few labs implementing the two types, I still am having trouble understanding when to use/implement either one. I don't understand why you'd need two different method types. Couldn't you set any method with a void...
  30. H

    Comp Sci Looping Through ASCII Art in Java: Solving a Homework Predicament

    ..so, we have been assigned a homework to print a certain ASCII art using only loops and methods. We can also use the built-in math methods such as the exponential one and whatnot. Basically, we have been asked to print an increasing loop that goes as follows: * ***...
  31. M

    Comp Sci How can I convert a binary string to decimal using Java?

    I'm trying to make a program that prompts a user to enter a binary number and then converts the string into integers by using Integer.parseInt. Right now though, I'm having trouble with tokenizing the string. My code works when I use the predefined variable temp but not when I enter the same...
  32. D

    Java Simple Java class + driver program help. Program isn't working, but should be.

    Hi :) I'm taking my first java course. I took two C++ courses last year, and I understand OOP pretty decently, but I cannot get this java program to work! And I'm beginning to get really frustrated because I can't find my mistake. This is my class file: package studentsjav; __________...
  33. A

    Java Troubleshooting Java6 & Java 1.4 in Netbeans 6.9.1

    I have Netbeans IDE 6.9.1 installed on my computer,and I was trying to enter the following code in a new project: 01 public class Hello 02 { 03 // 是程序的起点,所有程序由此开始运行 04 public static void main(String args[]) 05 { 06 // 此语句表示向屏幕上打印"Hello World !"字符串 07...
  34. T

    Comp Sci Trying to implement my own iterator in Java

    Homework Statement Basically, I am assigned to implement my own iterator using a Doubly Linked List. The methods, of course, are hasNext(), next(), and remove(). The one that is giving me the most grief is the remove() method. Homework Equations The Attempt at a Solution The...
  35. J

    C/C++ Are there any good sources for learning Java as an experienced C++ programmer?

    I'm an experienced C++ programmer looking to learn Java SE 7. Because of the similarities of the language, you'd think there would be a tutorial out there suited for such people but I'm having trouble finding one. I've looked at a couple of Java tutorials that are tailored to C++ programmers...
  36. S

    Java How can I count the number of times a loop runs in Java?

    For my class I need to make a "Guessing Game" Program. Basically you just pick a number between 1-1000. It tells you if you are too high, too low, or correct. If your too high or low you guess again until you get it right. When you get it right it is supposed to tell you how many tries it took...
  37. P

    Java Java - What do parameter lists do?

    In class the other day, my professor had written this as part of the lecture notes: Thus, this definition was mentioned as part of methods. He then went on to show an example of this as in the following: public class Dog { private Collar _ collar; public Dog(Collar collar) {...
  38. A

    Java Learn Java Programming: UML Necessary?

    I want to start learning Java programming,by myself. I got some PDF books. In the introduction, it talks about UML, but I find it complicated. I want to know whether it is a must to read the theory part, or I can just start on the practical part.
  39. H

    Java Java program that prints 1000 times.

    Okay. So, I'm taking up a beginning Java course in college and we have been assigned a rather simple (?) homework. We have to code a program that prints a statement a thousand times, but without the use of loops, only methods. I know I can create a method that contains a number of the...
  40. pairofstrings

    Java Explaining "this" Keyword in Java with an Example

    Hello everyone. I want explanation of the working of 'this' keyword in java. I read articles but couldn't understand. Please help me here. I don't understand what objects and variables they are talking about. Also give me an example of what object, variable, instance variable is. Box(double...
  41. R

    Comp Sci How to Handle Duplicate Entries in a Java Array?

    Homework Statement Write an application that inputs ten numbers from the user, each number can be between 10 and 100, inclusive. As each number is read in determine if it is a number already entered. If it is a duplicate move on to the next number, if it is unique store the number in the...
  42. pairofstrings

    Java What tools do I need to practice Java programs on my PC?

    what tools or software is required to start practising java programs on my pc?
  43. A

    Comp Sci How Do You Implement Recursive Insertion Sort for Arrays of Strings in Java?

    im having a little trouble getting started with this. it is for an array of strings. would i do insertion sort the same was as if it was an array of ints or doubles but use the compareTo method to see if i should switch two elements? this is my attempt so far, it won't compile due to the...
  44. S

    Java Java: Fix Error & Read File Args to Variables

    Hello, I am just starting to learn Java. I have a small file that needs reading in, line by line, with different arguments. Such a line looks like this: 123 Midterm .25 100 456 TakehomeExam .25 200 0 Quiz03 .10 25 1 Final .40 100 I need to read these in as separate variables. I...
  45. K

    Comp Sci CAN SOMEONE PLEASE explain the this. keyword in java to me?

    CAN SOMEONE PLEASE explain the "this." keyword in java to me?! "the this keyword can be used to refer to the calling object or used inside one constructor to invoke another in its own class. I understand how it invokes another constructor. But i do not understand why i keep seeing this code...
  46. M

    Comp Sci Why Does My Java Program Say Cannot Find Method?

    I'm trying to create a program that derives a class named Student from the class Person, and then I'll test everything in the main program in TestStudent. What I'm having trouble with at the moment, is calling the methods correctly. Whenever I try to call a method in the main program, I get this...
  47. A

    Comp Sci Understanding Java Recursive Array Reversal

    supposed to reverse an array of strings recursively. this is in a class that has an array object. i came up with what's below. but it reverses the array in a weird order. the array is a 5 element array, the elements are {hello, how, are you, ?}. i passed in the object and after printed out...
  48. T

    Java Java: Creating my own Linked List

    Hello everyone. My task here is to construct my own linked list. The outer class is SLList and the inner class is Node. The problem that I seem to be having is when I try to use the fields of the outer class in the inner class, I am getting "cannot make static reference to the non-static field."...
  49. K

    Comp Sci NEED immediate help with enumerated data types JAVA

    okay so i have my program basically done, i just have one problem and it has to do with an enumerate data type i created public enum PaintColor {RED, BLACK, WHITE, BLUE, GREEN, OTHER}; in my class that is UsedCars im tracking attributes of these objects [used cars] now...on my TestUsedCars...
  50. M

    Java Why is My Java Airplane Seating Chart Program Not Working Properly?

    I've been working on this and I can't figure out why, exactly, it's not working properly. I can reserve a seat 4A but when I try to reserve seat 6A, the output includes a line of string that says "The seat you requested is unavailable. Please make another selection." yet it still let's me make...
Back
Top