I need to write a class that represents and image of RGB pixels. This class uses a two-dimensional array of object type that represents R,G and B values.
When I compile the class it completes successfully. However, when I try running a "tester" class , I'm encountering errors in a few methods. I've been trying it out for 2 days now, but unsuccessfully thus far..Those method are : rotating the image by 90 degrees clockwise (and vice versa , but I just use clockwise method 3 times for that) , shifting the image sideways, and shifting the image up/down..
I've attached the whole source code for the class , and the list of errors I get when I try to run my tester. URL...
I am new to JSP and I'm having a problem with captcha containing a value in the field when toggling from the first page to another and clicking submit on the second page before entering data to validate the fields and the code just falls through and returns the error "Please enter the correct code". The values returned are (captcha)96043 (code)null, captcha is not null because it is retrieved from session which is the last value captured from the page I'm assuming.
I've used request.getSession().removeAttribute( "captcha" ); before building the page to clear out the values, resetting captcha to null etc.; nothing is working.
My objective is to write a program that calculates the bodyfat of people. The difficult thing is, that the calculations are different for males and females, so I tried to prompt the user to state whether they are male or female, then use and "if" statement to tether their response to the corresponding calculations.
Here's my algorithm:
Here's what I have:
package bodyweight; import java.util.Scanner; public class Weightcalc { static Scanner console = new Scanner(System.in); public static void main(String[] args){
[Code] ....
It keeps telling me that bodyweight is not initialized, but when I do, I get a hell of a lot more bugs on everything telling me they aren't initialized. I just want the program to transfer the user to select inputs, based on whether they are male or female.
Scanner sc = new Scanner(System.in); Question question = new Question(); Quiz quiz = new Quiz(); System.out.print("Enter the prompt: "); question.prompt = sc.nextLine();
[Code] .....
Here is the example run that I am trying to achieve:
* 1. Enter the prompt: What is the capital of the USA? * 2. Enter a possible answer: New York City, NY * 2. Is New York City, NY the correct answer (y/n)? n * 3. Enter a possible answer: Pittsburgh, PA * 3. Is Pittsburgh, PA the correct answer (y/n)? n * 4. Enter a possible answer: Washington, DC * 4. Is Washington, DC the correct answer (y/n)? y * 5. Enter a possible answer: Chicago, IL * 5. Is Chicago, IL the correct answer (y/n)? n
The problem is that my for loop runs through correctly the first time, but doesn't seem to react to me initializing my choices array after that. It ends up looking like this:
Enter the prompt: What is the capitol of the USA? Enter a possible answer: New York City, NY Is New York City, NY the correct answer (y/n)?n Enter a possible answer: Is the correct answer (y/n)?
struct myHAI { int id; char celcius[5]; char fahrenheit[5];
[Code] .....
I think the Java code is just a little to kludgey. I have to add 256 records to the 3D array which means I have to call the method 256 times. I'd really like to initialize the class all at once similar to the C struct. But I don't know if that is possible. Thus, any less kludgey way of initializing a 3D array?
I am writing a program with different screens. At first you have to log in to access the program. So I have a problem with the variables username and password. I can't seem to get theme from the DbConnection class. I suppose it is a basic problem?
In the DbConnection class i have a problem with the returns.
In the Login class i have a problem with the connection.getUsername(); and connection.getPassword();
Here is some code:
class DbConnection package kim.contracts.database; import java.sql.*; public class DbConnection { private Connection conn; private Statement st; private ResultSet rs;
So, this is weird for me because I don't really understand why the BorderLayout class constructor is being initialized as a parameter for the setLayout..
I don't understand that the error occurs when I don't initialize the variable myPoint. Whereas, I initialize the variable myPoint after variable declaration and before place of error.
package enumeration; import java.util.Random; public class Craps {
[Code]....
When I initialize the variable myPoint to zero in its decleration, the error disappear. But why? I have already initialized the variable myPoint in default case before the line of error occured..
i know that int [][] x = new int[2][2] will generate a 2x2 array but I'm looking at a certification mock question and I see double [][] da = new double [3][]. What is the empty [] on the right hand side of the equal sign trying to tell me? Is there some default value?
public class Check2 { private int red; private int green; private int blue;
public Check2(){ red = 0; green = 0; blue = 0;
[Code] .....
And when i uses it in another class named "Check" it returns zeroes :
public class Check { public static void main(String[] args) { Check2 obj = new Check2(125,254,12); // the toString method should return the values i gave it here . but it shows me zeroes instead. System.out.println("the colors are " + obj.toString()); } }
I need to pass user input from the main method, which is then validated using another method that is returned as a valid score, and then I pass the valid input to another method that stores the data in an array. The array is initialized within the method. I tried to use an if-else statement to initialize the array, because I originally did this at the beginning of the method. I soon learned that I was creating a new array everything I accessed the method. Needless to say, this isn't working either.
public static void main(String[] args) { int judges = 7; float[] validScores = new float[judges]; for (int i = 0; i < judges; i++) { float score = -1;
I mainly would like to know is a int[4][4] or a int [4*4] is more efficient to use. Which takes more storage? Which requires more to process? that kind of stuff.
I can understand result 3 is because of an upcast from short to int, since FunWithOverloading will not have a overloaded method with short now. However, what is happening with result 4? Shouldn't it call methodA of the subclass with the argument type short? If its because I have declared the reference variable, derived, of the type FunWithOverloading, then how come the first result correctly picks the overloaded method of the sub class?
class FunWithOverloading{ void methodA(int x){System.out.println("Integer method " + x);} void methodA(short x){System.out.println("Short method " + x);} //line 3 } class OverloadedSubClass extends FunWithOverloading{ void methodA(short x){System.out.println("Sub class short method " + x);}
how objects relate to classes and how you can create and re-use object types.on that point, but this has me baffled. I most certainly do not have a firm grasp yet on passing things to and from methods that just makes my head hurt. SO anyway I tried out one of the code examples:
/* ElectricGuitar.java */ class ElectricGuitar { String brand; int numOfPickups; boolean rockStarUsesIt;
[code]...
But I just realized this thing has no main method and only one class defined.....so I guess I just tried to compile.
I am trying to understand the concept of Generics in java. In the introduction to Generic Types, this example is given:
Java Code: public class Box { private Object object; public void set(Object object) { this.object = object; } public Object get() { return object; } } mh_sh_highlight_all('java'); "Since
Since its methods accept or return an Object, you are free to pass in whatever you want, provided that it is not one of the primitive types." - I understand this.But then it has been changed to a generic class:
Java Code: /** * Generic version of the Box class. * @param <T> the type of the value being boxed */ public class Box<T> { // T stands for "Type" private T t;
public void set(T t) { this.t = t; } public T get() { return t; } } mh_sh_highlight_all('java'); "
As you can see, all occurrences of Object are replaced by T. A type variable can be any non-primitive type you specify: any class type, any interface type, any array type, or even another type variable."We can use any type in place of an Object, because Object is a superclass of all classes. But T (or any other class) is not a superclass of all classes. So how do we justify any class being used in place of a random T or any other class?
public class AutoBoxingExample { public void add(Integer intVal){ System.out.println("Wrapper"); } public void add(int value){ System.out.println("Primitive"); } public static void main(String[] args) { AutoBoxingExample auto = new AutoBoxingExample(); auto.add(12); } }
The output is "Wrapper". What would be the reason behind it?
GoodEmployee is defined who has ALL the following properties:
He should be married. He should have 2 or less than 2 children. His middle name should start with "k" but not end with "e" The last name should have more than 4 characters The character "a" should appear in the last name at least two times. The name of one of his children should be "Raja"
isMarried true if the employee is married. noOfChild the number of children of the employee. middleName the middle name of the employee lastName the last name of the employee. childNames the array of the names of the children of the employee
import javax.swing.JOptionPane; public class Input { public static void main(String[] args) { int user; user = JOptionPane.showMessageDialog(null, "Enter Your Age""); ERROR IS HERE if(user <= 18) { JOptionPane.showMessageDialog(null, "User is legit"); } else { JOptionPane.showMessageDialog(null, "User is not legit"); } } }
I'm getting this error message :
incompatible types: void cannot be converted to int
I am looking at a snippet of code in my "learning Java 4th edition" by Orielly and there is a small snipped of code which says:
Java Code: Date date = new Date(); List list = new ArrayList(); list.add( date ); ..
Date firstElement = (Date)list.get(0); // Is the cast correct? Maybe. mh_sh_highlight_all('java'); so I am typing the same thing in my compiler in a small Driver class and for some reason I have an error and Im dumbfounded...