SlideShare a Scribd company logo
1 of 9
Download to read offline
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

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.pdfanurag1231
 
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.pdfSANDEEPARIHANT
 
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.pdfarjuncorner565
 
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.pdfakkhan101
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003R696
 
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 .pdfRahul04August
 
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.docxMARRY7
 
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.pdfformicreation
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good TestsTomek 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.pdffatoryoutlets
 
R. herves. clean code (theme)2
R. herves. clean code (theme)2R. herves. clean code (theme)2
R. herves. clean code (theme)2saber tabatabaee
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry 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.pdffantasiatheoutofthef
 
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.pdfDEEPAKSONI562
 

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.pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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 .pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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 .pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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 .pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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 .pdfAroraRajinder1
 
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.pdfAroraRajinder1
 
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.pdfAroraRajinder1
 

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

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 

Recently uploaded (20)

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 

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