Message from @Paragram Slide - AZ
Discord ID: 495327364339859472
@GDoctor taught it for many years, I can probably help
What are you looking at?
@ThisIsChris I'm In calculus 1 right now and there are no prerequisites however, it assumes a high school background in pre-calculus. The problem is that high school was over 10 years ago for me and I didn't do well in it. I'm going to post a scan of my latest homework and would like to know how to solve the problems in layman's terms. The scientific calculator I have is a TI-84 Plus.
Here's my current homework. It's due September 5th.
@GDoctor here is 1a and 1b
@ThisIsChris Thank you very much! I'm signed up for tutoring at my school so hopefully I'll catch up and remember how to do this stuff in my head. Tests account for 85% of my final grade.
<@&435155896780324864> Can someone tell me why I'm getting a null pointer exception in Java?
?
how do you paste code?
```java
import java.lang.*;
```
\`\`\`java
code
\`\`\`
```java
public boolean contains(Object o) {
for (int i = 0; i < size; i++) {
if (o == null && get(i).data == null) {
return true;
}
else if (get(i).data.equals(o)) {
return true;
}
}
return false;
}
```
```java
public ListNode get(int index) throws IndexOutOfBoundsException{
ListNode cur = head;
for (int i = 0; i < index; i++) {
if (i == index) {
return get(i);
}
cur = cur.next;
}
return null;
}
```
pls no bully I haven't taken Java in two years and now I have to relearn everything
get(i).equals
make the first && an ||
but I'm checking to see if they're both null
but the elseif
o could be null
```java
// Returns true if this list contains the specified element o.
// More formally, returns true if and only if this list contains at least one element e
// such that (o==null ? e==null : o.equals(e)).
// Note: you have to handle the case where a list node stores null data element.
```
and get(i).data could be null
do this
Object.equals(get(i).data, o)
in the else if
handles nulls
says that the method is not applicable for arguments
Objects.equals
ah
not Object
I still get a null pointer exception from the if statement
this is what is being tested btw
```java
public static void testContains() { //passed test
init();
System.out.println("----------------testContains()------");
System.out.println(list0.contains(null));
System.out.println(list2.contains("1:Good"));
System.out.println(list2.contains("6:Tony"));
System.out.println(list2.contains("notexist"));
System.out.println(list2.contains(""));
System.out.println(list2.contains(null));
System.out.println(list3.contains("notexist"));
System.out.println(list3.contains(null));
drawLine();
}
```
that is from the tester class, not the same class
break when cur is null
it shouldn't break though
it should theoretically be able to find objects with data set to null
cur.next
cur is never null?
recursively
no it should be null at the last node