SlideShare a Scribd company logo
Keep getting a null pointer exception for some odd reason
im creating the variable and the object but it still isnt working
My code is below please help
package classes;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class NewClass4
{
private class Node
{
private String text;
private int Hit;
private int Miss;
private Node next;
public Node(String text, int Hit, int Miss, Node next)
{
this.text=text;
this.Hit=Hit;
this.Miss=Miss;
this.next=next;
}
public void incrementHit()
{
this.Hit = this.Hit+1;
}
public void incrementMiss()
{
this.Miss = this.Miss+1;
}
public String getText()
{
return this.text;
}
public int getHit()
{
return this.Hit;
}
public int getMiss()
{
return this.Miss;
}
}//end of node
private class LL
{
public Node head;
public LL()
{
head=null;
}
public void insert(String text2, boolean isHit)
{
System.out.println("entered insert method");
Node temp=this.head;
System.out.println("sent temp node to head");
while((temp!=null) && (!temp.text.equals(text2)) )
{
temp=temp.next;
}
if(temp==null)
{
// we did not find the string
if(isHit)
{
this.head=new Node(text2,1, 0, this.head );
}
else
{
this.head=new Node(text2,0, 1, this.head );
}
}
else
{
if(isHit)
{
temp.incrementHit();
}
else
{
temp.incrementMiss();
}
}
}//end of insert
public void printList()
{
Node temp=this.head;
while(temp!=null)
{
int Hit=temp.getHit();
int Miss=temp.getMiss();
double sucRate=Hit*100/(Hit+Miss);
System.out.println(temp.getText() + " " + sucRate);
}
}
}// end of LL
private static LL myLL;
public NewClass4()
{
this.myLL = new LL();
}
public static void main(String[] args)
{
SimpleDateFormat sdf = new
SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss",Locale.ENGLISH);
String myString = null;
Pattern a = Pattern.compile("[0-9]{2}/?[A-Za-z]{3,4}/?[0-9]{4}[.,-:]{1}[0-9.,-
:]{1,}s+");
Pattern d= Pattern.compile("s+/+[0-9.]{3}/+[A-Za-z]{1,}/+[A-Za-z.,-:%]{1,}");
Pattern f= Pattern.compile("s+[0-9]{3}s+");
String newLine;
try {
File file = new File("myFile.txt");
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String line;
while ((line = bufferedReader.readLine()) != null)
{
myString = line;
System.out.println(myString);
Matcher m1 = a.matcher(myString);
Matcher m2 = d.matcher(myString);
Matcher m3 = f.matcher(myString);
if (m1.find() && m2.find()&& m3.find())
try {
Date parsedDate = sdf.parse(m1.group());
SimpleDateFormat print = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
int responseCode = Integer.parseInt(m3.group().trim());
System.out.println(print.format(parsedDate)+ " "+m2.group()+" "+responseCode);
newLine = print.format(parsedDate)+ " "+m2.group();
// decide true or false
if (responseCode >= 500 )
{
if (NewClass4.myLL == null)
{
System.out.println("Link List is empty");
}
NewClass4.myLL.insert(newLine, false);
}
else
{
NewClass4.myLL.insert(newLine, true);
}
} // end of second try
catch (ParseException e)
{
e.printStackTrace();
}
}// end of while
fileReader.close();
//System.out.println("Contents of file:");
}//end of first try
catch (IOException e)
{
e.printStackTrace();
}
//Classes.myLL.printList();
}// end of main
}// end of Classes
Solution
package classes;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class NewClass4 {
private class Node {
private String text;
private int Hit;
private int Miss;
private Node next;
public Node(String text, int Hit, int Miss, Node next) {
this.text = text;
this.Hit = Hit;
this.Miss = Miss;
this.next = next;
}
public void incrementHit() {
this.Hit = this.Hit + 1;
}
public void incrementMiss() {
this.Miss = this.Miss + 1;
}
public String getText() {
return this.text;
}
public int getHit() {
return this.Hit;
}
public int getMiss() {
return this.Miss;
}
}// end of node
private class LL {
public Node head;
public LL() {
head = null;
}
public void insert(String text2, boolean isHit) {
System.out.println("entered insert method");
Node temp = this.head;
System.out.println("sent temp node to head");
while ((temp != null) && (!temp.text.equals(text2))) {
temp = temp.next;
}
if (temp == null) {
// we did not find the string
if (isHit) {
this.head = new Node(text2, 1, 0, this.head);
} else {
this.head = new Node(text2, 0, 1, this.head);
}
} else {
if (isHit) {
temp.incrementHit();
} else {
temp.incrementMiss();
}
}
}// end of insert
public void printList() {
Node temp = this.head;
while (temp != null) {
int Hit = temp.getHit();
int Miss = temp.getMiss();
double sucRate = Hit * 100 / (Hit + Miss);
System.out.println(temp.getText() + " " + sucRate);
}
}
}// end of LL
private static LL myLL;
public NewClass4() {
this.myLL = new LL();
}
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss",
Locale.ENGLISH);
String myString = null;
Pattern a = Pattern
.compile("[0-9]{2}/?[A-Za-z]{3,4}/?[0-9]{4}[.,-:]{1}[0-9.,-:]{1,}s+");
Pattern d = Pattern
.compile("s+/+[0-9.]{3}/+[A-Za-z]{1,}/+[A-Za-z.,-:%]{1,}");
Pattern f = Pattern.compile("s+[0-9]{3}s+");
String newLine;
try {
File file = new File("myFile.txt");
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String line;
while ((line = bufferedReader.readLine()) != null) {
myString = line;
System.out.println(myString);
Matcher m1 = a.matcher(myString);
Matcher m2 = d.matcher(myString);
Matcher m3 = f.matcher(myString);
if (m1.find() && m2.find() && m3.find())
try {
Date parsedDate = sdf.parse(m1.group());
SimpleDateFormat print = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm");
int responseCode = Integer.parseInt(m3.group().trim());
System.out.println(print.format(parsedDate) + " "
+ m2.group() + " " + responseCode);
newLine = print.format(parsedDate) + " " + m2.group();
// decide true or false
if (responseCode >= 500) {
if (NewClass4.myLL == null) {
System.out.println("Link List is empty");
}
NewClass4.myLL.insert(newLine, false);
} else {
NewClass4.myLL.insert(newLine, true);
}
} // end of second try
catch (ParseException e) {
e.printStackTrace();
}
}// end of while
fileReader.close();
// System.out.println("Contents of file:");
}// end of first try
catch (IOException e) {
e.printStackTrace();
}
// Classes.myLL.printList();
}// end of main
}// end of Classes
myFile.txt
2011-06-14T04:12
2013-06-14T04:12
2012-06-14T04:12
Note: Please make sure the path of the file is in the project location, i think that is the problem

More Related Content

Similar to Keep getting a null pointer exception for some odd reasonim creati.pdf

Java VS Python
Java VS PythonJava VS Python
Java VS Python
Simone Federici
 
AnswerNote Provided code shows several bugs, hence I implemented.pdf
AnswerNote Provided code shows several bugs, hence I implemented.pdfAnswerNote Provided code shows several bugs, hence I implemented.pdf
AnswerNote Provided code shows several bugs, hence I implemented.pdf
anurag1231
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdf
SANDEEPARIHANT
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
arjuncorner565
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4Abed Bukhari
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
akkhan101
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003
R696
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdf
Rahul04August
 
Table.java Huffman code frequency tableimport java.io.;im.docx
 Table.java Huffman code frequency tableimport java.io.;im.docx Table.java Huffman code frequency tableimport java.io.;im.docx
Table.java Huffman code frequency tableimport java.io.;im.docx
MARRY7
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
formicreation
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
Tomek Kaczanowski
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdf
fatoryoutlets
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
KamalSaini561034
 
R. herves. clean code (theme)2
R. herves. clean code (theme)2R. herves. clean code (theme)2
R. herves. clean code (theme)2
saber tabatabaee
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
Dmitry Sheiko
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
fantasiatheoutofthef
 
06slide.ppt
06slide.ppt06slide.ppt
06slide.ppt
RohitNukte
 
Java generics
Java genericsJava generics
Java generics
Hosein Zare
 
4.3 Hibernate example.docx
4.3 Hibernate example.docx4.3 Hibernate example.docx
4.3 Hibernate example.docx
yasothamohankumar
 
Team public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfTeam public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdf
DEEPAKSONI562
 

Similar to Keep getting a null pointer exception for some odd reasonim creati.pdf (20)

Java VS Python
Java VS PythonJava VS Python
Java VS Python
 
AnswerNote Provided code shows several bugs, hence I implemented.pdf
AnswerNote Provided code shows several bugs, hence I implemented.pdfAnswerNote Provided code shows several bugs, hence I implemented.pdf
AnswerNote Provided code shows several bugs, hence I implemented.pdf
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdf
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdf
 
Table.java Huffman code frequency tableimport java.io.;im.docx
 Table.java Huffman code frequency tableimport java.io.;im.docx Table.java Huffman code frequency tableimport java.io.;im.docx
Table.java Huffman code frequency tableimport java.io.;im.docx
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdf
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 
R. herves. clean code (theme)2
R. herves. clean code (theme)2R. herves. clean code (theme)2
R. herves. clean code (theme)2
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
 
06slide.ppt
06slide.ppt06slide.ppt
06slide.ppt
 
Java generics
Java genericsJava generics
Java generics
 
4.3 Hibernate example.docx
4.3 Hibernate example.docx4.3 Hibernate example.docx
4.3 Hibernate example.docx
 
Team public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfTeam public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdf
 

More from AroraRajinder1

In class, we talked about all sorts of experiments. I would like to s.pdf
In class, we talked about all sorts of experiments. I would like to s.pdfIn class, we talked about all sorts of experiments. I would like to s.pdf
In class, we talked about all sorts of experiments. I would like to s.pdf
AroraRajinder1
 
Jane Lee was employed as a secretary at Burton Trucking. She was fire.pdf
Jane Lee was employed as a secretary at Burton Trucking. She was fire.pdfJane Lee was employed as a secretary at Burton Trucking. She was fire.pdf
Jane Lee was employed as a secretary at Burton Trucking. She was fire.pdf
AroraRajinder1
 
If a function F) performs the following operations, what knd of cohe.pdf
If a function F) performs the following operations, what knd of cohe.pdfIf a function F) performs the following operations, what knd of cohe.pdf
If a function F) performs the following operations, what knd of cohe.pdf
AroraRajinder1
 
How would a subculture appear if a colony containing both S. Marce.pdf
How would a subculture appear if a colony containing both S. Marce.pdfHow would a subculture appear if a colony containing both S. Marce.pdf
How would a subculture appear if a colony containing both S. Marce.pdf
AroraRajinder1
 
Hint Assume the binary tree is properly balanced (the depth of the .pdf
Hint Assume the binary tree is properly balanced (the depth of the .pdfHint Assume the binary tree is properly balanced (the depth of the .pdf
Hint Assume the binary tree is properly balanced (the depth of the .pdf
AroraRajinder1
 
essay question Explain how everyday life changes for slaves after e.pdf
essay question Explain how everyday life changes for slaves after e.pdfessay question Explain how everyday life changes for slaves after e.pdf
essay question Explain how everyday life changes for slaves after e.pdf
AroraRajinder1
 
Detection versus recognition ... Investigate Face++ at Feel free to.pdf
Detection versus recognition ...  Investigate Face++ at  Feel free to.pdfDetection versus recognition ...  Investigate Face++ at  Feel free to.pdf
Detection versus recognition ... Investigate Face++ at Feel free to.pdf
AroraRajinder1
 
Dent disease is a rare disorder of the kidney in which reabsorption o.pdf
Dent disease is a rare disorder of the kidney in which reabsorption o.pdfDent disease is a rare disorder of the kidney in which reabsorption o.pdf
Dent disease is a rare disorder of the kidney in which reabsorption o.pdf
AroraRajinder1
 
DEFINE maternal determinant (3-4 sentences).SolutionMaternal .pdf
DEFINE maternal determinant (3-4 sentences).SolutionMaternal .pdfDEFINE maternal determinant (3-4 sentences).SolutionMaternal .pdf
DEFINE maternal determinant (3-4 sentences).SolutionMaternal .pdf
AroraRajinder1
 
Consider a partial function.For every unmapped element in its doma.pdf
Consider a partial function.For every unmapped element in its doma.pdfConsider a partial function.For every unmapped element in its doma.pdf
Consider a partial function.For every unmapped element in its doma.pdf
AroraRajinder1
 
Compare and Contrast hollow core fibers for high power delivery an.pdf
Compare and Contrast hollow core fibers for high power delivery an.pdfCompare and Contrast hollow core fibers for high power delivery an.pdf
Compare and Contrast hollow core fibers for high power delivery an.pdf
AroraRajinder1
 
Can we create an object of type Interface Explain your answer.So.pdf
Can we create an object of type Interface Explain your answer.So.pdfCan we create an object of type Interface Explain your answer.So.pdf
Can we create an object of type Interface Explain your answer.So.pdf
AroraRajinder1
 
Cancel QuestionSolutionSince Descriptive statistics uses the d.pdf
Cancel QuestionSolutionSince Descriptive statistics uses the d.pdfCancel QuestionSolutionSince Descriptive statistics uses the d.pdf
Cancel QuestionSolutionSince Descriptive statistics uses the d.pdf
AroraRajinder1
 
According to the cladogram, what derived trait is shared by primates .pdf
According to the cladogram, what derived trait is shared by primates .pdfAccording to the cladogram, what derived trait is shared by primates .pdf
According to the cladogram, what derived trait is shared by primates .pdf
AroraRajinder1
 
A male Flagus fly with the Barkus phenotype is crossed with a female.pdf
A male Flagus fly with the Barkus phenotype is crossed with a female.pdfA male Flagus fly with the Barkus phenotype is crossed with a female.pdf
A male Flagus fly with the Barkus phenotype is crossed with a female.pdf
AroraRajinder1
 
2015Matthew and Michael Goode (cousins) decide to form a partners.pdf
2015Matthew and Michael Goode (cousins) decide to form a partners.pdf2015Matthew and Michael Goode (cousins) decide to form a partners.pdf
2015Matthew and Michael Goode (cousins) decide to form a partners.pdf
AroraRajinder1
 
1. Jose is a Latino client who presents with occupational difficulti.pdf
1. Jose is a Latino client who presents with occupational difficulti.pdf1. Jose is a Latino client who presents with occupational difficulti.pdf
1. Jose is a Latino client who presents with occupational difficulti.pdf
AroraRajinder1
 
You have a small business customer who wants to use a voice over IP .pdf
You have a small business customer who wants to use a voice over IP .pdfYou have a small business customer who wants to use a voice over IP .pdf
You have a small business customer who wants to use a voice over IP .pdf
AroraRajinder1
 
Why can some microbial species grow and survive in extreme environ.pdf
Why can some microbial species grow and survive in extreme environ.pdfWhy can some microbial species grow and survive in extreme environ.pdf
Why can some microbial species grow and survive in extreme environ.pdf
AroraRajinder1
 
Which prokaryotic group maps most closely to the chlorophyll of plan.pdf
Which prokaryotic group maps most closely to the chlorophyll of plan.pdfWhich prokaryotic group maps most closely to the chlorophyll of plan.pdf
Which prokaryotic group maps most closely to the chlorophyll of plan.pdf
AroraRajinder1
 

More from AroraRajinder1 (20)

In class, we talked about all sorts of experiments. I would like to s.pdf
In class, we talked about all sorts of experiments. I would like to s.pdfIn class, we talked about all sorts of experiments. I would like to s.pdf
In class, we talked about all sorts of experiments. I would like to s.pdf
 
Jane Lee was employed as a secretary at Burton Trucking. She was fire.pdf
Jane Lee was employed as a secretary at Burton Trucking. She was fire.pdfJane Lee was employed as a secretary at Burton Trucking. She was fire.pdf
Jane Lee was employed as a secretary at Burton Trucking. She was fire.pdf
 
If a function F) performs the following operations, what knd of cohe.pdf
If a function F) performs the following operations, what knd of cohe.pdfIf a function F) performs the following operations, what knd of cohe.pdf
If a function F) performs the following operations, what knd of cohe.pdf
 
How would a subculture appear if a colony containing both S. Marce.pdf
How would a subculture appear if a colony containing both S. Marce.pdfHow would a subculture appear if a colony containing both S. Marce.pdf
How would a subculture appear if a colony containing both S. Marce.pdf
 
Hint Assume the binary tree is properly balanced (the depth of the .pdf
Hint Assume the binary tree is properly balanced (the depth of the .pdfHint Assume the binary tree is properly balanced (the depth of the .pdf
Hint Assume the binary tree is properly balanced (the depth of the .pdf
 
essay question Explain how everyday life changes for slaves after e.pdf
essay question Explain how everyday life changes for slaves after e.pdfessay question Explain how everyday life changes for slaves after e.pdf
essay question Explain how everyday life changes for slaves after e.pdf
 
Detection versus recognition ... Investigate Face++ at Feel free to.pdf
Detection versus recognition ...  Investigate Face++ at  Feel free to.pdfDetection versus recognition ...  Investigate Face++ at  Feel free to.pdf
Detection versus recognition ... Investigate Face++ at Feel free to.pdf
 
Dent disease is a rare disorder of the kidney in which reabsorption o.pdf
Dent disease is a rare disorder of the kidney in which reabsorption o.pdfDent disease is a rare disorder of the kidney in which reabsorption o.pdf
Dent disease is a rare disorder of the kidney in which reabsorption o.pdf
 
DEFINE maternal determinant (3-4 sentences).SolutionMaternal .pdf
DEFINE maternal determinant (3-4 sentences).SolutionMaternal .pdfDEFINE maternal determinant (3-4 sentences).SolutionMaternal .pdf
DEFINE maternal determinant (3-4 sentences).SolutionMaternal .pdf
 
Consider a partial function.For every unmapped element in its doma.pdf
Consider a partial function.For every unmapped element in its doma.pdfConsider a partial function.For every unmapped element in its doma.pdf
Consider a partial function.For every unmapped element in its doma.pdf
 
Compare and Contrast hollow core fibers for high power delivery an.pdf
Compare and Contrast hollow core fibers for high power delivery an.pdfCompare and Contrast hollow core fibers for high power delivery an.pdf
Compare and Contrast hollow core fibers for high power delivery an.pdf
 
Can we create an object of type Interface Explain your answer.So.pdf
Can we create an object of type Interface Explain your answer.So.pdfCan we create an object of type Interface Explain your answer.So.pdf
Can we create an object of type Interface Explain your answer.So.pdf
 
Cancel QuestionSolutionSince Descriptive statistics uses the d.pdf
Cancel QuestionSolutionSince Descriptive statistics uses the d.pdfCancel QuestionSolutionSince Descriptive statistics uses the d.pdf
Cancel QuestionSolutionSince Descriptive statistics uses the d.pdf
 
According to the cladogram, what derived trait is shared by primates .pdf
According to the cladogram, what derived trait is shared by primates .pdfAccording to the cladogram, what derived trait is shared by primates .pdf
According to the cladogram, what derived trait is shared by primates .pdf
 
A male Flagus fly with the Barkus phenotype is crossed with a female.pdf
A male Flagus fly with the Barkus phenotype is crossed with a female.pdfA male Flagus fly with the Barkus phenotype is crossed with a female.pdf
A male Flagus fly with the Barkus phenotype is crossed with a female.pdf
 
2015Matthew and Michael Goode (cousins) decide to form a partners.pdf
2015Matthew and Michael Goode (cousins) decide to form a partners.pdf2015Matthew and Michael Goode (cousins) decide to form a partners.pdf
2015Matthew and Michael Goode (cousins) decide to form a partners.pdf
 
1. Jose is a Latino client who presents with occupational difficulti.pdf
1. Jose is a Latino client who presents with occupational difficulti.pdf1. Jose is a Latino client who presents with occupational difficulti.pdf
1. Jose is a Latino client who presents with occupational difficulti.pdf
 
You have a small business customer who wants to use a voice over IP .pdf
You have a small business customer who wants to use a voice over IP .pdfYou have a small business customer who wants to use a voice over IP .pdf
You have a small business customer who wants to use a voice over IP .pdf
 
Why can some microbial species grow and survive in extreme environ.pdf
Why can some microbial species grow and survive in extreme environ.pdfWhy can some microbial species grow and survive in extreme environ.pdf
Why can some microbial species grow and survive in extreme environ.pdf
 
Which prokaryotic group maps most closely to the chlorophyll of plan.pdf
Which prokaryotic group maps most closely to the chlorophyll of plan.pdfWhich prokaryotic group maps most closely to the chlorophyll of plan.pdf
Which prokaryotic group maps most closely to the chlorophyll of plan.pdf
 

Recently uploaded

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 

Recently uploaded (20)

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 

Keep getting a null pointer exception for some odd reasonim creati.pdf

  • 1. Keep getting a null pointer exception for some odd reason im creating the variable and the object but it still isnt working My code is below please help package classes; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.io.*; import java.util.*; import java.text.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class NewClass4 { private class Node { private String text; private int Hit; private int Miss; private Node next; public Node(String text, int Hit, int Miss, Node next) { this.text=text; this.Hit=Hit; this.Miss=Miss; this.next=next; } public void incrementHit() { this.Hit = this.Hit+1; } public void incrementMiss()
  • 2. { this.Miss = this.Miss+1; } public String getText() { return this.text; } public int getHit() { return this.Hit; } public int getMiss() { return this.Miss; } }//end of node private class LL { public Node head; public LL() { head=null; } public void insert(String text2, boolean isHit) { System.out.println("entered insert method"); Node temp=this.head; System.out.println("sent temp node to head"); while((temp!=null) && (!temp.text.equals(text2)) ) { temp=temp.next; } if(temp==null) { // we did not find the string if(isHit)
  • 3. { this.head=new Node(text2,1, 0, this.head ); } else { this.head=new Node(text2,0, 1, this.head ); } } else { if(isHit) { temp.incrementHit(); } else { temp.incrementMiss(); } } }//end of insert public void printList() { Node temp=this.head; while(temp!=null) { int Hit=temp.getHit(); int Miss=temp.getMiss(); double sucRate=Hit*100/(Hit+Miss); System.out.println(temp.getText() + " " + sucRate); } } }// end of LL private static LL myLL; public NewClass4()
  • 4. { this.myLL = new LL(); } public static void main(String[] args) { SimpleDateFormat sdf = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss",Locale.ENGLISH); String myString = null; Pattern a = Pattern.compile("[0-9]{2}/?[A-Za-z]{3,4}/?[0-9]{4}[.,-:]{1}[0-9.,- :]{1,}s+"); Pattern d= Pattern.compile("s+/+[0-9.]{3}/+[A-Za-z]{1,}/+[A-Za-z.,-:%]{1,}"); Pattern f= Pattern.compile("s+[0-9]{3}s+"); String newLine; try { File file = new File("myFile.txt"); FileReader fileReader = new FileReader(file); BufferedReader bufferedReader = new BufferedReader(fileReader); String line; while ((line = bufferedReader.readLine()) != null) { myString = line; System.out.println(myString); Matcher m1 = a.matcher(myString); Matcher m2 = d.matcher(myString); Matcher m3 = f.matcher(myString); if (m1.find() && m2.find()&& m3.find()) try { Date parsedDate = sdf.parse(m1.group()); SimpleDateFormat print = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); int responseCode = Integer.parseInt(m3.group().trim()); System.out.println(print.format(parsedDate)+ " "+m2.group()+" "+responseCode); newLine = print.format(parsedDate)+ " "+m2.group(); // decide true or false if (responseCode >= 500 ) {
  • 5. if (NewClass4.myLL == null) { System.out.println("Link List is empty"); } NewClass4.myLL.insert(newLine, false); } else { NewClass4.myLL.insert(newLine, true); } } // end of second try catch (ParseException e) { e.printStackTrace(); } }// end of while fileReader.close(); //System.out.println("Contents of file:"); }//end of first try catch (IOException e) { e.printStackTrace(); } //Classes.myLL.printList(); }// end of main }// end of Classes Solution package classes; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */
  • 6. import java.io.*; import java.util.*; import java.text.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class NewClass4 { private class Node { private String text; private int Hit; private int Miss; private Node next; public Node(String text, int Hit, int Miss, Node next) { this.text = text; this.Hit = Hit; this.Miss = Miss; this.next = next; } public void incrementHit() { this.Hit = this.Hit + 1; } public void incrementMiss() { this.Miss = this.Miss + 1; } public String getText() { return this.text; } public int getHit() { return this.Hit; } public int getMiss() { return this.Miss; } }// end of node private class LL { public Node head; public LL() {
  • 7. head = null; } public void insert(String text2, boolean isHit) { System.out.println("entered insert method"); Node temp = this.head; System.out.println("sent temp node to head"); while ((temp != null) && (!temp.text.equals(text2))) { temp = temp.next; } if (temp == null) { // we did not find the string if (isHit) { this.head = new Node(text2, 1, 0, this.head); } else { this.head = new Node(text2, 0, 1, this.head); } } else { if (isHit) { temp.incrementHit(); } else { temp.incrementMiss(); } } }// end of insert public void printList() { Node temp = this.head; while (temp != null) { int Hit = temp.getHit(); int Miss = temp.getMiss(); double sucRate = Hit * 100 / (Hit + Miss); System.out.println(temp.getText() + " " + sucRate); } } }// end of LL private static LL myLL; public NewClass4() {
  • 8. this.myLL = new LL(); } public static void main(String[] args) { SimpleDateFormat sdf = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss", Locale.ENGLISH); String myString = null; Pattern a = Pattern .compile("[0-9]{2}/?[A-Za-z]{3,4}/?[0-9]{4}[.,-:]{1}[0-9.,-:]{1,}s+"); Pattern d = Pattern .compile("s+/+[0-9.]{3}/+[A-Za-z]{1,}/+[A-Za-z.,-:%]{1,}"); Pattern f = Pattern.compile("s+[0-9]{3}s+"); String newLine; try { File file = new File("myFile.txt"); FileReader fileReader = new FileReader(file); BufferedReader bufferedReader = new BufferedReader(fileReader); String line; while ((line = bufferedReader.readLine()) != null) { myString = line; System.out.println(myString); Matcher m1 = a.matcher(myString); Matcher m2 = d.matcher(myString); Matcher m3 = f.matcher(myString); if (m1.find() && m2.find() && m3.find()) try { Date parsedDate = sdf.parse(m1.group()); SimpleDateFormat print = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm"); int responseCode = Integer.parseInt(m3.group().trim()); System.out.println(print.format(parsedDate) + " " + m2.group() + " " + responseCode); newLine = print.format(parsedDate) + " " + m2.group(); // decide true or false if (responseCode >= 500) { if (NewClass4.myLL == null) { System.out.println("Link List is empty");
  • 9. } NewClass4.myLL.insert(newLine, false); } else { NewClass4.myLL.insert(newLine, true); } } // end of second try catch (ParseException e) { e.printStackTrace(); } }// end of while fileReader.close(); // System.out.println("Contents of file:"); }// end of first try catch (IOException e) { e.printStackTrace(); } // Classes.myLL.printList(); }// end of main }// end of Classes myFile.txt 2011-06-14T04:12 2013-06-14T04:12 2012-06-14T04:12 Note: Please make sure the path of the file is in the project location, i think that is the problem