My input is:
"Static methods and variables are not linked to objects of the class; they are linked to the class itself.
If we create ten Variables objects (see the example at the beginning of this level), we will have ten instanceVariable
variables (one for each object) and only one shared (static) variable TEXT."
"When you call a method using <object> dot <method name>, you're actually calling a class method and passing that same object as
the first argument. Inside the method, the object is called 'this'. All operations in the method are performed on this object and its data."
"When you call a static method, no object is passed to it. In other words, 'this' equals null. That's why a static method can't
access non-static variables and methods (since it has no 'this' to pass to these methods)."
output:
["Static methods and variables are not linked to objects of the class; they are linked to the class itself. , If we create ten Variables objects (see the example at the beginning of this level), we will have ten instanceVariable , variables (one for each object) and only one shared (static) variable TEXT.", , "When you call a method using <object> dot <method name>, you're actually calling a class method and passing that same object as , the first argument. Inside the method, the object is called 'this'. All operations in the method are performed on this object and its data.", , "When you call a static method, no object is passed to it. In other words, 'this' equals null. That's why a static method can't , access non-static variables and methods (since it has no 'this' to pass to these methods)."]
package com.codegym.task.task15.task1525;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/*
File in a static block
*/
public class Solution {
public static List<String> lines = new ArrayList<>();
public static void main(String[] args) throws IOException{
BufferedReader reader = new BufferedReader(new FileReader(Statics.FILE_NAME));
while(reader.ready()){
String a = reader.readLine();
lines.add(a);
}
reader.close();
System.out.println(lines);
}
}