Alpha
JCHJava Community | Help. Code. Learn.
•Created by Alpha on 1/10/2024 in #java-help
What is necessary for creating a gps like app?
I lost something valuable and have no way of finding it so I want to know if it's possible for a beginner level programmer to create a custom tracking app to negate another situation like this or if It's way over my head.
4 replies
JCHJava Community | Help. Code. Learn.
•Created by Alpha on 5/16/2023 in #java-help
Issue turning a node linkedlist to generic type node linkedlist (this is what I tried)
public class LinkedListf<E> {
static class node <E>{
E data;
node<E> next;
node(E value) {
data = value;
next = null;
}
}
static node head;
// display the list
static void printList() {
node p = head;
System.out.print("\n[");
//start from the beginning
while(p != null) {
System.out.print(" " + p.data + " ");
p = p.next;
}
System.out.print("]");
}
//insertion at the beginning
void insertatbegin(E data) {
//create a link
node lk = new node(data);
// point it to old first node
lk.next = head;
//point first to new first node
head = lk;
//pointing old node to new node
}
void deletedata(E data){
node del = head;
node prev = null;
if(del != null && del.data == data){
head= del.next;
return;
}
while (del != null && del.data != data){
prev = del;
del= del.next;
}
prev.next=del.next;
}
void insertafter(E index, E data){
node sert = head;
//node prev = null;
node ins = new node(data);
while (sert != null){
if(sert.data == index){
ins.next = sert.next;
sert.next = ins;
break;
}
sert = sert.next;
}
}
public static void main(String args[]) {
int k=0;
insertatbegin(12);
insertatbegin(22);
insertatbegin(30);
deletedata(12);
insertafter(44, 2);
System.out.println("Linked List: ");
// print list
printList();
}
} //issue is im not sure if its correct, and I get a cannot run from a static point because I had to change the functions from static when trying to call the functions in MAIN as is.
164 replies