import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
import java.awt.event.*;
/* display selected number
if selected, bg is green
if not selected bg is pink
*/
[code]....
my compiler is telling me that the getList... method is not being overridden.but when I change the JList<String> to JList and Object to String in the parameters, i get a warning from the compiler that it's an "unchecked call".
So the first thing I would like to ask about is overriding inherited methods. I am asked to override methods in one of my assignments and I am not really sure how to go about doing it.
What does this error mean, and also, when I get it, the command line hangs so that I can't do anything else (Is there a way to recover from that?). I'm running Windows 7.
Jan 03, 2015 5:00:59 AM java.util.prefs.WindowsPreferences <init> WARNING: Could not open/create prefs root node SoftwareJavaSoftPrefs at root 0 x80000002. Windows RegCreateKeyEx(...) returned error code 5.
When I run the following code from Java HeadFirst, everything goes fine but along with one error ( i don't know is it an error or exception, or some other windows stuff). The code is
import javax.sound.midi.*; class ExceptionHandling { public static void main(String[] args){ ExceptionHandling o = new ExceptionHandling(); o.play();
[Code] ....
And what I got on cmd ( I am using Windows 7) :
Jaspreet javac ExceptionHandling.java Jaspreet java ExceptionHandling Jun 11, 2014 5:19:40 PM java.util.prefs.WindowsPreferences <init> WARNING: Could not open/create prefs root node SoftwareJavaSoftPrefs at root 0 x80000002. Windows RegCreateKeyEx(...) returned error code 5.
We got the sequencer
What is meant by code in blue? I know its some message from windows os and not from jvm. but i didn't understand it.
public void init(Board board) { JPanel Panel = new JPanel(); Panel.setLayout(new GridLayout(board.getWidth(), board.getHeight())); getContentPane().add(Panel, BorderLayout.CENTER); Panel.setBorder(new LineBorder(Color.BLACK)); // it does not work also
[code]....
I have a JFrame. I added two JPanels to the JFrame. The first one is GridLayout and it should be situated at CENTER. Another one is bottomPanel, and that one should be situated at SOUTH.I would like to add two new JPanels(kit and another one) to the bottomPanel.Compiler does not show any warning or errors.The problem is, that bottomPanel situates at NORTH, not at SOUTH. kit situates at CENTER of bottomPanel, not at WEST.
There are 2 methods and a main one. The first is a void that creates a 3x4 2d array and the second is to search for a value in the array, if found it will return the number of the row that contains that value. If not, it will return -1, but I am getting 1 error and 1 dead code warning.I will put comments at the lines that contain the problems
import java.util.Scanner; class Question4{ public static void main(String[]args){ Scanner s = new Scanner(System.in); int x,n; System.out.println("Please input the value that will be used in the array"); x=s.nextInt(); System.out.println("What is the value you want to search for?"); n=s.nextInt(); createArray (x,n);
import javax.swing.JFrame; public class groupingTest { public static void main (String[] args) { groupWindow test = new groupWindow();
[Code]....
At the start of the groupWindow it turns yellow and it says "The serializable class groupWindow does not declare a static final serialVersionUID field of type long".
This the output of java from my PC under linux platform (rhel 6.5).
[pentaho@vertica-srv1 Downloads]$ java -version java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
[Code] ....
But the problem is while trying to open ETL program under linux platform [pentaho@vertica-srv1 data-integration]$ ./spoon.sh .... I received the following error messages.
Trying to add database driver (JDBC): RmiJdbc.RJDriver - Warning, not in CLASSPATH? Trying to add database driver (JDBC): jdbc.idbDriver - Warning, not in CLASSPATH? Trying to add database driver (JDBC): org.gjt.mm.mysql.Driver - Warning, not in CLASSPATH? Trying to add database driver (JDBC): com.mckoi.JDBCDriver - Warning, not in CLASSPATH? [KnowledgeFlow] Loading properties and plugins...
I am getting notification about "The value of the local variable result not used" in my program when i am using boolean data type.But code execution was successful. Results are also displayed accurately.I am using Eclipse, there i i have noticed this warning.
* program to practice about comparison operators */ public class compoperators { public static void main(String[] args) { boolean result; }
class One { public static void doStuff() { System.out.println("One"); } }
class Two extends One
[code]....
My understanding of static says that static methods cannot be overrriden but the compilation of the above code results in Overriding rule violation error.
I have a question: I have a Java/JSP/JavaScript project that access back end Oracle database, and provide interaction through tomcat. After we deployed our project, I found one button does not generate necessary warning message from server, but when I deployed and tested our project on local PC, it does generate correct warning message. I am using the same IE, same tomcat version, and I am sure my container is pointing to the same database, and I am sure I using same version of project code by checking with GIT.
public class RealignServlet extends SiapBaseServlet { private static final long serialVersionUID = 1L; private static final Logger logger = AppLogger.getLogger(RealignServlet.class.getName()); private static final String PROC_QUERY_JSP = "ProcQuery.jsp"; private static final String REALIGN = "REALIGNMENT";
[Code] .....
Our problem is server could not generate alignMsg. But we can get it on local deployed project.
/* * Implement the Comparable interface on objects of type Order. * Compare orderId, then productId. The lesser orderId should come first. If the orderIds match, then the lesser productId should come first. */
@Override public int compareTo(Order ord) { // TODO Auto-generated method stub if(orderId > ord.orderId){ return 1;
In short, the "Actual" is what my code produces and the "Expected" is what it is supposed to produce. As you can see, only the first one is mismatching... I'll admit, the comment section above the method is confusing and I wasn't exactly sure what it wants me to do, but I thought I figured it out. I just don't see how 5/6 of these tests can work and the 6th one not.
For a few days I've been reading about the importance of overriding the equals method. How overriding it actually determines or checks the values stored in the variable. I realize that you can check the values stored in the primitive datatypes with "==", and when you don't override the equals method it acts the same way, right? When used with a reference datatype, "==" or the default equals() method only compares, or sees, if the variable is pointing to the same instance of a class. For some reason, in the examples, what is taking place to actually check the values stored inside the variables.
Here is part of an example (I've added comments for things that are confusing me):
@Override public boolean equals(Object obj) { //So we use Object here instead of the class type // we're overriding this equals method for? Is this so that we can use it to check different types? (overloading?) if (obj == this) { return true;
//Isn't this checking to see if the calling object is the same as the object we're passing to it? Why doesn't this return false? } if (obj == null || obj.getClass() != this.getClass()) { return false; }
//How exactly do we check the values stored in each object though? }
what im trying to do is modify the Coin class to override the toString() method so that it indicates whether the coin is face up or face down. For example, "The coin is face up." This is what i have so far:
public class Coin { public static void main(String[] args) { Coin coin = new Coin(); for (int i = 0; i < 1; i++) { coin.flip(); System.out.println(coin);
I am attempting to override the equals method from the Object class which checks if two variables point towards the same object. I want the method to check if if the argument being passed in(an object) has the same data(instance variables) as the object that's calling this method. A NullPointerException is being thrown; Here is the code.
Exception in thread "main" java.lang.NullPointerException at javaapplication5.Product.equals(Product.java:42) at javaapplication5.Product.main(Product.java:24) Java Result: 1
How do i print override the toString for WebBrowser as i would like to print out the object bc. Tested the program and it is fine if i put it in the main method rather than the WebBrowser constructor.
import java.util.*; class ListNode <E> { /* data attributes */ private E element; private ListNode <E> next; /* constructors */ public ListNode(E item) { this(item, null);
class SubB{ public void foo(){ System.out.println(" x"); } } public class X extends SubB { public void foo() throws RuntimeException{ super.foo(); if(true) throw new RuntimeException(); System.out.println(" B"); } public static void main(String [] args){ new X().foo(); } }
Why the foo method of class X is not throwing a compile error because according to the override rule, if the superclass method has not declared exception, the subclass method can't declare a new exception...
I have two classes (Daughter and Son) that contain some very similar method definitions:
public class Family { public static void main(String[] args) { Daughter d = new Daughter(); Son s = new Son(); d.speak(); s.speak();
[Code] .....
Each of those classes has a "speak" method with two out of three lines being identical. I could move those into a parent class, but I need each of the child classes to continue to exhibit its unique behavior. I'm trying the approach below, which replaces the unique code with a call to a "placeholder" method that must be implemented by each child class:
public class Family { public static void main(String[] args) { Daughter d = new Daughter(); Son s = new Son();
[Code] .....
This works and moves the shared code from two places (the Daughter and Son classes) into one place (the new Mother class, which is now a parent class of Daughter and Son). Something about this feels a bit odd to me, though. It's one thing for a child class to override a parent class's methods to extend or alter their behavior. But, here, I've implemented an abstract method in the parent class to alter what happens when the parent class's method (speak(), in this case) is called, without overriding that parent class method itself.
I have written two methods called "contains" and "overlaps". The method "contains" is to detemine whether a point (x, y coordinate) is within the surface area of a square object. The location of the square objects is determined by the location of the upper left corner of the square.The method "overlaps" is to determine whether two square objects overlap each other.
I have written these as two separate methods. However I want to change the method "overlaps", so that it uses the method "contains" within it. I.e. using a method within a method. Thereby hopefully making the "overlaps" method a bit more clear and easy to read.
Java Code:
/** Returns true of the point with the coordinates x,y, are within the square. */ public boolean contains(int x, int y){ int sx = location.getX(); //"location" refers to a square object int sy = location.getY(); // getX() and getY() are to find it's coordinates // "side" is the side length of the square if (x >= sx && x <= (sx + side) && y >= sy && y <= (sy + side)){
Below is the main class of a project ive been working on, the goal is to start a countdown specified by the user. When the countdown reaches zero the base drops in the song that is being played. (Its not done yet) The main problem that arises is the fact that my song plays, and AFTER that, the timer starts.
Output:
Please input countdown in HH:mm:ss format. 00:00:41 Start? Yes
The name of of the song is: Skrillex & Damian "Jr Gong" Marley - "Make It Bun Dem"
The time of base drop is: 00:00:41 //Song starts here
//Song is done //Then timer starts 00:00:41 00:00:40 00:00:39
I have following code. In this code CSClient is an interface. All methods of CSClient are implementaed in CSClientImpl class. Do I not need CS Client Impl imported in this code ?
How can I call getBranch() of CSClient, which is not implemented in CSClient as " this. getCsClient(). get Branch (new CSVPath(vpath), true);" ? This code works fine without any error in eclipse.
How can a method getBranch(), which is implemented in CSClientImpl class be used in this code without importing CSClientImpl ?
Write the header for a method named send that has one parameter of type String, and does not return a value.Write the header for a method named average that has two parameters, both of type int, and returns an int value.