|
import java.util.*;
class One
{
public static String city;
public static void main(String args[])
{
city=args[0];
Two t= new Two();
}
}
class Two extends One
{
public Two()
{
if(city=="Banglore")
System.out.println("Hello BANGLORE");
}
}
|
|
|
|
|
what is the advantage of declaring each variable in separate line?
Zaki
|
|
|
|
|
|
I have been coding java for a few months and have a good understanding of it. I just have a few questions on certain things I wanna do.
I need help understanding the A* algorithm and how to code it. I'm trying to code mobs with AI that follow the player around.
I need to know how to implement sounds via the source code.
If it is necessary to know this, know that I am using Eclipse to code and Processing for graphics and stuff like that.
Any help will be greatly appreciated!
|
|
|
|
|
You need to use Google to find information about different algorithms, as they are not specific to Java. And for specific Java questions Google should also lead you to the documentation pages, such as Trail: Sound (The Java™ Tutorials)[^].
|
|
|
|
|
Gametron13 wrote: I need help understanding the A* algorithm and how to code it
Following provides examples in google
A* algorithm java
Just as a suggestion if you have never programmed before then doing what you are doing is is going to be rather ambitious. So you should expect that it will be difficult. Focusing on one part and making it as simple as possible, with the goal of making it better in the future might be more rewarding especially if the goal it to learn how to program.
|
|
|
|
|
HashMap Internal working. and which scenario use in java tech.
|
|
|
|
|
Member 13437687 wrote: HashMap Internal working
Yes it is working.
Member 13437687 wrote: and which scenario use in java tech.
The one that requires a hash. Find the problem first then the solution. Not the other way around.
Or conversely google for when to use it.
|
|
|
|
|
|
For example:
Enter the user input : 25
The number 25 should be encircled by some shapes. This is what I am looking for. Thanks in Advance
|
|
|
|
|
1. Decide which shapes to use
2. Write some UI code to display the shapes
3. Decide how a 'number' gets mapped to a shape.
4. Write some UI code that accepts number
5. Build a app that encapsulates the above and hooks it together.
|
|
|
|
|
after logout in servlet how to prevent browser back button to stop loading previously visted page
|
|
|
|
|
Rather certain as asked you cannot.
However what can happen is that the server, not the browser, can refuse to serve up any data (whatever that might be) after logout occurs. Should however already be doing that. If it is not then that is a problem with the server not the browser code.
|
|
|
|
|
I have a wav file that is supposed to play a sound when my image is clicked. The image only plays the sound when clicked if the wav file is within its while loop. But if the wav is within the while loop, my class runs out of memory... Has anyone ever had this problem? I would include the snippet of it but it would be useless without the program as a whole (138 lines) which is against discussion rules. I am also a new programmer.
|
|
|
|
|
Quote: my class runs out of memory. That is the first issue you need to correct.
|
|
|
|
|
You have a reference to one or more data structures when you load and play the wave file. Those take memory, both for the structures and the content of the wave file.
Each time this happens in your while loop you create those.
They never go away.
So you run out of memory.
You need to modify your code so it loads the wav file once and only once.
|
|
|
|
|
Hello India 123
Demo India
|
|
|
|
|
So being nice I will presume that either this was just a test message or it was not understand how to ask a question.
If the first then probably should delete.
If the second then a question should asked with details about it.
|
|
|
|
|
Hello!
In the next code, I've made a singly linked list.
In the AddNODE line(obj1) I called the AddNODE function, function which receives as parameter an object obj1 of type NODE.
The problem is the AddNODE(NODE newNode) function.
This newNODE must be an object or I think it would be like this.
Can you help me ?
class Persons
{
public String firstName;
public String secondName;
public String CNP;
public String Email;
};
class NODE
{
private NODE next;
public Persons box = new Persons();
public NODE(String firstName, String secondName, String CNP, String Email)
{
box.firstName = firstName;
box.secondName = secondName;
box.CNP = CNP;
box.Email = Email;
}
public NODE GetNext()
{
return next;
}
public void SetNext(NODE next)
{
this.next = next;
}
};
class SinglyLinkedList
{
private NODE head;
public SinglyLinkedList()
{
head = null;
}
public boolean isEmpty()
{
return head == null;
}
public void AddNODE(NODE newNode)
{
NODE temp = null;
if (isEmpty())
head = temp = newNode;
else
{
temp.SetNext(newNode);
temp = newNode;
}
temp.SetNext(null);
}
public void Print()
{
NODE temp = head;
while (temp != null)
{
System.out.print("\n First Name : " + temp.box.firstName);
System.out.print("\n Second Name : " + temp.box.secondName);
System.out.print("\n CNP : " + temp.box.CNP);
System.out.print("\n Email : " + temp.box.Email);
temp = temp.GetNext();
System.out.print("\n");
}
}
};
public class MyClass
{
public static void main(String args[])
{
SinglyLinkedList ptr = new SinglyLinkedList();
NODE obj1 = new NODE("Dragu", "Stelian", "1811226284570", "dragu_stelian@yahoo.com");
NODE obj2 = new NODE("Popescu", "Mircea", "1891226284462", "popescu.mircea@yahoo.com");
ptr.AddNODE(obj1);
ptr.AddNODE(obj2);
ptr.Print();
}
}
|
|
|
|
|
Your AddNODE method does not take account of the situation when head Is not null . Also you should set the next node pointer to null For a newly created node.
|
|
|
|
|
Please check again
public boolean isEmpty()
{
return head == null;
}
public void AddNODE(NODE newNode)
{
NODE temp = null;
if (isEmpty())
head = temp = newNode;
else
{
temp.SetNext(newNode);
temp = newNode;
}
temp.SetNext(null);
}
I am getting this error:
Exception in thread "main" java.lang.NullPointerException
at SinglyLinkedList.AddNODE
|
|
|
|
|
Yes, because you are still not connecting the new nodes to the head pointer. Try drawing a picture of a correctly linked list to see what head needs to point to.
|
|
|
|
|
If you can't see the problem, use the debugger to step through your code.
NODE temp = null; if (isEmpty()) { <-- false, execute "else" block else { temp.SetNext(... <-- BOOM! temp is still null here.
You need to decide whether the new node belongs at the start of the list, or at the end of the list.
If it belongs at the start, you set its next node to be the head, and set the head to be the new node.
public void AddNODE(NODE newNode)
{
newNode.SetNext(head);
head = newNode;
}
If it belongs at the end, you need to find the last node in the list, and set that node's next node to be the new node. If the list is empty, then set the head to be the new node.
public void AddNODE(NODE newNode)
{
if (isEmpty())
{
head = newNode;
}
else
{
Node last = head;
Node temp = last.GetNext();
while (temp != null)
{
last = temp;
temp = last.GetNext();
}
last.SetNext(newNode);
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
how to connect the finger print scanner in java and how to store the database in sql server 2008 R2
|
|
|
|
|
1. Research the scanner. Learn about the APIs that exist to interface to it.
2. Create Java code to use the API in 1 which is appropriate to the app that needs to use it.
3. Create Java code for the database that is appropriate to the app that needs to use it.
4. Wire 2 and 3 into the app.
Could be other steps as well, such as if you have no idea how to do 3 then there would be another step to investigate various methodologies to use a database via Java.
Forgot to mention that what you store in the database actually depends on the data that the scanner returns. But regardless of the form it will be likely be 'binary' so the database will need a column that specifically stored binary data. So if you do not know the difference there you will need to investigate.
|
|
|
|