I tried this but it only gives me one letter that corresponds to the number
package pkg2911homework.pkg1;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner keys = new Scanner(System.in);
I want to make project about java communication with hardware (wiz110sr) via LAN (Rj45). And for example, my hardware have ip address 198.168.0.1 ; port: 1202, connected with my PC(via lan/Rj45). I want show the output (such as numbers and letters) from my hardware in console netbeans.
When I running my code, appear :
" Exception in thread "Thread-0" java.lang.RuntimeException: Uncompilable source code at mypkg.startListenForTCP$1.run(startListenForTCP.ja va:48) at java.lang.Thread.run(Thread.java:745) BUILD SUCCESSFUL (total time: 1 second) "
I am making a simple dice game and am using JOptionPane for my input, however, all input has to be a String. I need to be able to input an integer. 'note, I am using java JDK'.
When learning HashMaps in C++ I had to create the whole algorithm. In the code I created I could simply place a string into the method and it would store the names for me by turning the string into a integer and storing is accordingly. If there was a collision it would grow linearly at that location.
//play with Hash Tables void getNames(String names) { HashMap<String, Integer> map = new HashMap<String, Integer>(); map.put(names,22); }
How can I do this in Java. I read about them and look at examples and they all for the most part look like this.
I wrote a single player blackjack code and i want to play this game with multiplayers, which steps should i take to do this
package blackjack; import java.util.Random; import java.util.Scanner; public class Blackjack { public static void main(String[] args) { Random kagit=new Random ();
I can't figure out why my code doesn't work. My task is to replace for example ä=>ae, using this method String.charAt(int index). So here is my code:
public class pich { public static void main(String[] args) { String text = "Die süße Hündin Leica läuft in die Höhle des fülligen Bären "+ "Iliyan (ein Übergrößenträger), der sie zum Teekränzchen eingeladen hat."+ " An ihrem Öhrchen trägt sie modisch eine Ähre."; String textOhneUmlaute = "";
[Code] ....
when I launch my code I get the same String and nothing has changed
While using generics, are there cases when ? wildcard cannot be replaced with letters [A-Z]? So far , I was able to find only one case, it is when you want to have field pointing on generic instance without making class generic.
class OneClass { private LinkedList<?> myLL; }
In case above, as I understand, you cannot use [A-Z] without generalize OneClass. Are there any other cases, when there is no way except to use ? wildcard instead of letter [A-Z]?
I have devised a simple program that reads a file and then adds up al the integers in the file and print the result, for example if the file had the numbers 1 2 3 4 5 6 7 8 9 10 then the program would print 55
However i have trouble when non integers are put into the file for example if it was 1 2 3 string 4 5 6 test 7 8 9 10
then i get:
Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:840) at java.util.Scanner.next(Scanner.java:1461) at java.util.Scanner.nextInt(Scanner.java:2091) at java.util.Scanner.nextInt(Scanner.java:2050) at Week7.Task3.filereader(Task3.java:25) at Week7.Task3.main(Task3.java:14)
my code is as follows
package testing;
import java.util.*; import java.io.File; import java.io.IOException; public class summingInts { public static void main(String[] args) throws IOException { Scanner textfile = new Scanner(new File("intSum.txt"));
My professor is a man who enjoys making his students form large, but often simple symbols with smaller letters. That might not have clarified much, so let me demonstrate:
VVVVVVV VVVVV VVV V Or... X X X X X X X X X Or lastly... O O O O O O O O
My problem is, that I've always been bad at figuring out the logic behind these.
I can kinda' see it (somewhat) in my head though... I'd need a double for-loop which depend on the sizes, one that monitors the spaces and one that monitors the symbols, with some conditionals in there. How to make symbols like this, using letters, in Java.
I had to write a program for class using the method definition "public static char getNumber(char upperCaseLetter)" It compiles and runs but wont print out my final answer.
import java.util.Scanner; public class Phone_0104730303 { public static char getNumber(char upperCaseLetter) { char return_val = 0;
I have made a program, where the user types in a letter M, C or I to identify their major, if the user types m, c or i, my code does not work.
How could I make my program ignore if the letter is upercase or lowercase? My code is posted below. Can I do this in any easier way then adding this type of code for each lowercase letter?:
Java Code:
if (s.charAt(0) == 'm') System.out.print("Mathematics "); mh_sh_highlight_all('java');
My current code:
import java.util.Scanner; public class c4e18 { public static void main(String[]args){ Scanner input = new Scanner(System.in); System.out.print("Enter two characters: "); String s = input.nextLine(); if (s.charAt(0) == 'M')
I am trying to make a program that reads a word and display if the letters are in ascending order or not in ascending order(All kind of letters, capitals ). I have made a code but its not 100% correct. My code:
class Main { public static void main(String args[]) { System.out.print( "#Enter text : " ); String text = BIO.getString();
I am trying to sort out all lower case letters out of my text file into a new file. I am not very good with char values. My text file that is being read says
I've created a class that extends FilterReader, that is to be used to find certain sequences of letters. I plan on using this code to demonstrate an observer, observable design pattern later on. Here is my code:
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FilterReader; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.util.Arrays; public class CaroReaderV2 extends FilterReader {
[Code] .....
Now my question is, how do I go about testing this in a main class? How would I pass in a reader to the constructor? How would I make sure that everything is working correctly?
I want to make a method that takes a word and then checks if the word can be created from available letters. For example, if a word "johnson" can be created by using letters "jashoqwnon".
Now my goal is to make sure that if available letters contain a letter from the word, that letter is put into a String called result and then erased from the list of given letters. So, "johnson" and "jashoqwn" would produce the result "johns" and leave "aqw" unused.
Now the problem that I am facing is that I can't get Java not to use the same letter twice. So "johnson" and "jashoqwn" still gives "johnson".
I've tried everything in my power but I am missing something. Here is my code.
public static String makeAWord(String word, String letters){ String result = ""; for(int i = 0; i < word.length(); i++){ for(int j = 0; j < letters.length() ; j++){
How to do this editing the last 3 letters of a string that i retrieve from database.. I have a string "111-222-333-000" here's the sample what i want to happen was to edit the last 3 letters of the string ,,
i insert into database "111-222-333-000" then i retrieve it for editing but what i want to happen is when i retrieve it what i can only edit was the last 3 strings only
I started using Java a couple of days ago, If you haven't guessed I want to see if the user is typing a full name or not, but I'm actually not too concerned with any more complexity than I mentioned in the title. It's ok if an input like "GLba b" comes out positive.
Start with the tree.java program (Listing 8.1) and modify it to create a binary tree from a string of letters (like A, B, and so on) entered by the user. Each letter will be displayed in its own node. Construct the tree so that all the nodes that contain letters are leaves. Parent nodes can contain some non-letter symbol like +. Make sure that every parent node has exactly two children. Don’t worry if the tree is unbalanced. Note that this will not be a search tree; there’s no quick way to find a given node. You may end up with something like this:
It also says all Letters must be Leaves
Now I had it almost similar to that picture, but it wasn't right. So ive been working on it but im getting some very strange (and frustrating) output from the following methods.
Ive included the display method just for reference. The book told me to use it so I haven't edited it. I believe my main issue is with my (incomplete) insert() method. The output goes into an infinite loop despite having a return statement break the while loop when a character is inserted.
The way I see to solve the problem is just add a (+) whenever a new subtree needs to be created. Say I add A and B, then it first creates a subtree at the root with a (+) and afterwards lists A and B as its leaves. If I insert a C, it should be able to simply move to the right child of the root and deposit the C there.
Write a method named secondHalfLetters that accepts a string as its parameter and returns an integer representing how many of letters in the string come from the second half of the alphabet (that is, have values of 'n' through 'z' inclusive). Compare case-insensitively, such that uppercase values of 'N' through 'Z' also count. For example, the call secondHalfLetters("ruminates") should return 5 because the 'r', 'u', 'n', 't', and 's' come from the second half of the alphabet. You may assume that every character in the string is a letter.
I have a text file that has the results of rock paper scissors game.
R P S R P P
I need to have the first letter in each line assigned to player1 and the second letter in each line assigned to player 2. where to start. I have the file input correct. It is reading the file and I can separate ints from strings. I just don't know how to separate the strings.
I'm using HTMLEditor in my simple test application and I'm showing html text generated. I noticed that accented letters (à,è,ì, ect) are not escaped (àect ect). Looking at the source code I arrived to the class
com.sun.webkit.WebPage
In which the method I thinked is used is this:
public String getHtml(long frameID) { lockPage(); try { log.log(Level.FINE, "getHtml"); if (isDisposed) { log.log(Level.FINE, "getHtml() request for a disposed web page.");