Posts

Showing posts from December 27, 2018

Attempt to invoke virtual method '' on a null object reference [duplicate]

Image
-1 0 This question already has an answer here: What is a NullPointerException, and how do I fix it? 12 answers I'm getting this error "Attempt to invoke virtual method 'java.lang.String eecs1022.caps.Game.qa()' on a null object reference" I just want to know why im getting this error and how I can work around it. The game object is returns a string but for some reason it says its a null object. Here is my main class and my game class. MAIN: private Game game; private String question = ""; private String answer = ""; private int score = 1; private int qNum = 1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

Javascript create string with new lines from csv file

Image
0 Im trying to load csv file in React and then format it to be saved as a string with line breaks. The problem is this: After this code block: makeArrayString() { let array = this.state.tempData; let finalArray = ; array.forEach(function(element) { let joinedEl = element.join(","); finalArray.push(joinedEl + "n"); }); The console output looks like this: 0: "5.1,3.5,1.4,0.2,setosa↵" 1: "4.9,3,1.4,0.2,setosa↵" 2: "4.7,3.2,1.3,0.2,setosa↵" 3: "4.6,3.1,1.5,0.2,setosa↵" 4: "5,3.6,1.4,0.2,setosa↵" I cant send this kind of format to python script on server because of the ↵ char. However when this block of code gets executed: finalArray = finalArray + ""; finalArray.split("n").map((item, key) => {