Maybe some people have posted something like this before, but many questions are kind of convoluted and hard to understand, and I would like to get at the essence of my issue without going through 3 pages of unrelated code. My issue is this:
When I try to instantiate my class, it tells me it has to be static. I am very confused at this.
package project0;
import javax.swing.*;
import java.util.*;
import java.awt.Button;
public class Project0 {
public static void main(String[] args) {
Test7 lucky7 = new Test7(); //here is where I am instantiating my class and it gives "nonstatic variable this cannot be referenced from a static context."
}
class Test7{
Test7(){
String str1 = "Hello";
changeString(str1);
System.out.println(str1);
}
public void changeString(String str2){
str2 = "Goodbye";
}
}
If I change the test7 class to static it works, but I feel this is the opposite of what should be happening, as I thought static classes couldn't be instantiated.
edit: I guess I was mistaking static for abstract >.> but in that case what is different about a static class than a regular class. Still a bit confused.
Please try to make answers simple so I can understand