import java.util.HashSet;
import java.util.ArrayList;
public class Graph
{
double [] [] adj;
graph (double [] [] a)
{
adj= new double [a.length][a.length];
for (int i=0;i<a.length;i++)
for (int j=0;j<a.length;j++)
adj[i][j]=a[i][j];
}
C:UserscDesktopGraph.java:: error: invalid method declaration; return type required
graph (double [] [] a)
import java.util.Scanner; public class days { public EnumTest () { this.day = weeks/months/years} final int daysInMonth = 30; //constants final int monthsInYear = 12; final int daysInWeek = 7; public void convert()
[Code] ....
after compiling it shows invalid method declaration ; return type required.
Netbeans tells me it's an illegal start of expression during the initialisation of the interactWithUser method. public class InvertLetter {
/** * @param args the command line arguments */ public static void main(String[] args) { /** * String mit den Kleinbuchstaben. */ final String lowercase = "abcdefghijklmnopqrstuvwxyz";
I have one interface with three(more than one) method declaration. In the subclass that implements it I want to define only one method not all three not even blank definition of them.Is there any keyword or method for that. How to do it? Is it possible to do it? In GUI we use adapter classes to achieve it. What for console application?
Let's say within a class I create a method that takes care of creating a java swing layout with labels, buttons etc.. then attach an action listener (inner class) for each button to change a respective label text. All I would need is that the action listener method can access and modify the label as needed.
Have read about static, protected, private, getters and setters but honestly bit confused about which structure should be adopted as a best practice. Global static protected variables for the labels along with private inner classes implementing ActionListeners believe will do the trick and will be able to access the labels but not convinced this is good practice.
I'm new to Java and have been stuck on how to use a final declaration statement once it's made. Below is a class I'm creating with the intention of calling it under a main method. I don't understand if I'm supposed to do anything else, like do some sort of get/set, or if the final static line is all I need. And, I don't know how I call it to the main method once I do.
public class Shirt//class name. { int collarSize;//data field. int sleeveLength;//data field. public final static String MATERIAL = "cotton";//final data field for material.
I am not able to understand what does this URI exists at all ?? I feel it making things complex and meaningless or else i am missing something hidden and secret.
Whilst pre-preparing for java certification, one of the online mock exams has slightly confused me by saying my answer was incorrect for multi-dimension array 'declaration and instantiation'.
This is one of the answers i chose - which was marked as incorrect
a) int[][] array2d = {{123}, {4,5}};
Which looks absolutely fine to me.One of the other answers, which i agree is correct and so does the mock exam is
when a new object is created in Java it follows the idiom:
Object obj = new Object(); where the Object() constructor matches the object type Object.
But what if it doesn't? I understand from the Oracle Docs on creating objects and polymorphism that the constructor must be in that object's class or one of its subclasses. However, suppose we wanted to declare a new stack. My first instinct would be:
Stack s1 = new Stack(); But I assume it's valid to do it this way, too:
Object s2 = new Stack(); // Is there a difference here? What are we really saying about s2? I'm guessing s2 is simply an empty stack, but only has access to the Object class methods? I'm not sure why someone would ever do this, but I want to solidify my understanding of the Java hierarchy. Are there really any circumstances where someone would use a subclass's constructor when creating a new object?
What is exact difference between them? Another thing is when I check (a==b) it retuns me false, but when I check a.equals(b) it returns me with true. Why So?
I have an application that uses an object that is declared globally for the class. Within a method that is triggered by a user event, it creates a new object and assigns it to this global object declaration. My question is, when the object is overwritten multiple times by the user selecting the button that calls this method, will the older instances be garbage collected or is there still a reference to them? Is there any downfall to this logic and if so what would be a solution.
I have to implement all the stack methods in java such as push, pop empty, not using the ready methods but have to create them and to execute an exercise but is sth wrong with it
public class Stiva {
/** the problem is here how to declare the stack 1 and stack 2 and kreu(head) gjmax(size)*/
int Gjmax; int array[] = new int[Gjmax]; int kreu; private Stiva stiva1; private Stiva stiva2;
My project in eclipse..I get the error below when I run MyTagUser.jsp -
HTTP Status 500 - /jsp/MyTagUser.jsp(14,0) Attribute subTitle invalid for tag Header according to TLD org.apache.jasper.JasperException: /jsp/MyTagUser.jsp(14,0) Attribute subTitle invalid for tag Header according to TLD org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)...et
<html> <body> <!-- Here I am going to use scripting like scriptlet,expression and other element like jsp declaration element --> <%!int i=0;%> <%System.out.println("Scriptlet");%> <%=new String("Expression")%> </body> </html>
My code runs correctly when i run the clients one after another without using threads.I am getting this following error when i run my multi-threaded server. When a server accepts a client connection, ClientHandler is the thread that handles that client.Exception in thread "main"
java.io.StreamCorruptedException: invalid stream header at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:737) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:253) at comm.DOMTransfer.<init>(DOMTransfer.java:25) at ClientHandler.<init>(ClientHandler.java:18) at GridInfo.main(GridInfo.java:34)This is where the error occurs:input = new ObjectInputStream(socket.getInputStream());
import java.io.*; public class MagicSquare { public static void main(String[]args)throws IOException { BufferedReader in=new BufferedReader (new InputStreamReader(System.in)); System.out.print("Enter a Magic Number: "); int number=Integer.parseInt(in.readLine());
[Code] ....
//where should i enter a even number that will be outputted "invalid" //and it only should accept odd numbers
While doing trial and error got caught in the below scenario.
public class Crypt { public static void main (String args[]) { /*all I want is calculate a binary number (ex -: 22 , 34) using decimal base (10n). *So, I have to convert 2 p into 10n form so I have to find n in terms of p . We have x as the input. * The formula works as below. *2p =10n *p ln (2) =n ln (10) *n = p [ln(2) / ln(10)] *2 p = 10 p [ln(2) / ln(10)]
So today i was trying to compile a simple script that used to work before on Sublime Text 2, an i got the following error;
javac: invalid flag: Usage: javac <options> <source files> use -help for a list of possible options
I already know the script works because i didn't change anything since the last time it work, but anyways just in case i tried running a HelloWorld program just to check it out and i got the same error. The i stop trying to compiling the HelloWorld on Sublime so I went to Terminal and i got the same exact error.
I'm trying to establish an SSL connection (using a self-signed certificate). However, I can't seem to get the handshake to work. At the moment server side, I've created the public/private key + signed certificate and then stored them in a KeyStore. I've also stored this signed certificate in a KeyStore (trustStore) client side, so it can compare.