So I'm trying to check if the new coordinates vs original coordinates are diagonal and 1 line further, and if there is a piece there(getNum()) if it's 2 lines further, so I'm trying to return a boolean value then.
so if it's the first if, it returns true, if it's the 2nd it returns true, then I say else for all other scenario's, and return false there, but my compiler says my method is missing a return statement.
public boolean check(int[] d) {
int x,y;
x = loc[0][0];
y = loc[0][1];
int sx = d[0];
int sy = d[1];
[Code] .....
Edit: used a local boolean and returned that after my if's.,
This was an example of code that I'm trying to get to work, I swear I took it down just as it was written in class however mine says missing return statement....
Scanner keyb = new Scanner(System.in); System.out.print("enter rows and columns"); int rows = keyb.nextInt(); int cols = keyb.nextInt(); int[] [] array = new int [rows] [cols]; printArray(array);
I have been assigned to write a program that has a user input random numbers then the program is to sort them in different ways. I have the coding for the different sorts but, I have an error saying that I am missing a return statement in the "Bubble" method. I am trying to return "arr[i]" in the "for loop" which gives me this error, and when I try to take the "return arr[i]" outside of the "for()" loop the error reads the it cannot locate variable "i".
import java.awt.* ; import java.awt.event.*; import javax.swing.*; public class SwingSorts extends JFrame implements ActionListener { JRadioButton bubble; JRadioButton selection;
I want to use a method, which takes for example an int and also returns an integer. For example, if the the given integer is strong return a, if it is notstrong return b. How would you write that in a Code?
I want to use that in a more general way. I want to give a method mlong the value X of the type date and let it return an int. Type date consists of 3 int, one of them is the int month.
mlong should return an int depending on the X.moth. at the moment my code looks like this:
// File1: public class date { public int day; public int month; public int year; }
// File 2: public class monthlength { public int mlong(date X) { int t; t = X.month; if (t == 1 || t == 3 || t == 5 || t == 7 || t == 8 || t == 10 || t == 12) { return 31; } if(t == 4 || t == 6 || t == 9 || t == 11) {return 30;} } }
How do i take input values for TwoDPoint (which are objects) and return it back in numerical values also print them.
When i create an object in main method and pass values to my function of return type TwoDPoint,it gives error:- found int,int need TwoDPoiint,TwoDPoint.
// Here is what i tried to do:
Created class TwoDPoint that contains two fields x, y which are of type int. Defined another class TestTwoDPoint, where a main method is defined.In the main method created two TwoDPoint objects.
Then I modified the class TestTwoDPoint and add another function to it. This function takes two TwoDPoints as input and returns the TwoDPoint that is farthest from the point (0,0).
Then I added another function to TestTwoDPoint. This function takes two TwoDPoints as input and returns a new TwoDPoint whose x value is the sum of x values of the input TwoDPoint's and whose y value is the sum of the y values of the input TwoDPoint's.
class TwoDPoint { int x = 2; int y = 4; } class TestTwoDPoint { public static void main(String args[]) { TwoDPoint obj1 = new TwoDPoint(); System.out.println(obj1.x); System.out.println(obj1.y);
When I put this code in throw new IllegalStateOperation("SortType is invalid"); it states that it can't find the symbol IllegalStateOperation. What should I do to initialize the symbol/variable IllegalStateOperation?
Here is the entire code: :
class HairSalon implements Comparable<HairSalon> { static final int sortByService = 0, sortByPrice = 1, sortByTime = 2; private String service; private double price; private int time;
I am obviously new to programming and Java so I set myself the goal of creating a very simple auto type style of program so it gets the users input and relays it out again but potentially to another window (I am currently testing to notepad). The reason I am trying to make it is because i thought it could be quite simple and I can build on it as a project to make it better.
The issue I am having is that it outputs the first character to the window I am selected (again testing into notepad) but then stops and doesn't output anything else. I tried to figure out what was going on by putting a System.out.println(arr[6]); after the delay method but it just output a line so almost like what I was putting into the array was only storing the first character of the string? I cannot figure out why that would be...
import java.awt.*; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.util.Scanner; public class MyBot public static void main(String[] args) throws AWTException { //initialising robot Robot r = new Robot(); Scanner input = new Scanner(System.in);
Why do I see many exceptions for one missing file on the stack trace ? My guess is, where ever that file or methof is being called , all of them will throw exceptions. So, where do I find the root exception, first one which is thrown OR the last one ?
java.io.FileNotFoundException: c: emppw.txt (The system cannot find the file specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:120) at java.util.Scanner.<init>(Scanner.java:636) at com.rbc.ReportDriverRunner.getPassword(AuditReportDriverRunner.java:39)
[Code] ....
In the above stack trace, "java.io.FileNotFoundException: c: emppw.txt (The system cannot find the file specified)" is the root cause (Assuming there is only one error which causes code to fail) ? Is the first one cause of failure whch then cascades failure of other methods ?
I am very new to EJB. Started with Session bean demo which was working fine. (created a jar file which had EJB and a WAR file which had servlet). But face some issues when created MDB . (For that also created a JAR file which had EJB and a WAR file which had servlet).
I have used @JMSDestinationDefinitions({
@JMSDestinationDefinition(name = "java:global/jms/mySalutationQueue", interfaceName = "javax.jms.Queue") }) in servlet and @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:global/jms/mySalutationQueue") in MDB. I hope that's fine.
I am using WildFly 8 application server in "standalone-full" mode. But while deploying it I got some errors of missing dependencies. Trace of my application server log is as follows:
09:00:28,511 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named Salutation in deployment unit deployment "SalutationProject.war" are as follows:
This example is taken from the EJB 3.1 Cookbook's 1st Chapter. I have searched on [URL] .... but didnt get it. Have only used CDI annotations and no xml.
import java.util.*; //input from library of routines public class guessingGame { public static void main(String[] args) { int sN = 7; int yourGuess; int guessCount = 0;
[Code] ....
I'm getting an error that says identifier expected and the compiler points to this as the problem:("Pick a number between 1 and 10");
I'm writing a desktop client for simple soap service (axis), and when i create a web-service client lib using netbeans wsimport tool, I don't understand why for that entity :
Currently I try to integrate a JavaFX BarChart into my existing Java application. Therefore I need a BufferedImage of my BarChart, so that I can render that snapshot on a Graphics instance.
I adapted the existing BarChartSample.java (Chart Sample | JavaFX Tutorials and Documentation) and removed all animations. The code itselfs works fine but I identified one problem -> my TickLabels are missing
The TickLabels are visible If I use JDK 1.7u51 but if I change to JDK 1.8u05.... than the stlye of my BarChart will be changed and my tick labels are not visible.
I have a problem where I have to create random integers from 1 to n + 1. When the array is displayed I have to find the missing integer from the values that are displayed and show that value. I have to use O(n^2) and O(n) operations. I have created this code so far but I cannot figure out how to make my values display n + 1. It is only displaying values 1, 2, 3, 4 and 5 in random order. I also cannot figure out how to find the missing value. I have created a boolean displayed statement but can't determine how to use it in this code.
=Java import java.util.Random; public class Task6 { public static void main(String[] args) { int[] numbers = new int[7]; //create array of numbers Random random = new Random(); boolean displayed = false; //boolean value to determine if number was displayed
I want to use a method, which takes for example an int and also returns an integer. For example, if the the given integer is even return 1, if it is not even return 0. How would you write that in a Code?
I want to use that in a more general way. I want to give a method mlong the value X of the type date and let it return an int. Type date consists of 3 int, one of them is the int month.
mlong should return an int depending on the X.moth.
At the moment my code looks like this:
// File1:
public class date { public int day; public int month; public int year; }
// File 2:
public class monthlength { public int mlong(date X) { int t; t = X.month; if (t == 1 || t == 3 || t == 5 || t == 7 || t == 8 || t == 10 || t == 12) { return 31; } if(t == 4 || t == 6 || t == 9 || t == 11) {return 30;} } }
I am making a program which accepts two user inputs one being a letter either upper or lower case and the other being a number. the out come should be some thing like this:
G GG GGG GGGG GGGGG
This is assuming the user inputted 'G' and '5'.
here is the code i have so far:
package week10; import java.util.Scanner; public class integer { public static void main(String args[]) { Scanner user_input = new Scanner( System.in );
[Code] ....
The problem i am having is that i cant get the number that is inputted to be accepted as a variable to be used for the program.
how to determine if an integer is even or odd by using a boolean method. I think I have the method right, but it's calling the method into the main that has got me stumped.
import java.util.Scanner; public class Odd_Even { public static void main(String[] args) { //Scanner, variables Scanner input = new Scanner(System.in); int number;
code=Java import java.util.Random; import java.util.Scanner; public final class Derp { public static int WIN, Tick; public static Scanner Input = new Scanner(System.in);
[code]...
why this boolean statement isn't working correctly. It's not detecting that the WIN and Tick are the same and instead chooses to always run the second statement.