Need help improve the code
I have this file but I need to improve the code on some method. The methods are addNode, deleteNode, saveNode, findLader and are they anyway for me to iliminate the findsmallest method?
here is the code
import java.io.*;
import java.util.LinkedList;
import java.util.Stack;
import javax.swing.*;
public class Graph {
private LinkedList graph;
private BufferedReader inputFile;
public Graph() {
graph = new LinkedList();
// read the words from the given file
// create a GraphNode
// Add the node to the graph
public void createGraph(String fileName) throws IOException {
inputFile = new BufferedReader(
new InputStreamReader(new FileInputStream("word.txt")));
// Convert the linkedlist to an array 'a'
// sort the array 'a'
// create a string from all elements in 'a'
// return the string
public String printGraph() {
String output = new String();
// will contain String objects
// ... do some work with the list, adding, removing String objects
String[] a = new String[graph.size()];
graph.toArray(a);
// now stringArray contains all the element from linkedList
quickSort(a, 0, a.size() - 1);
for(int i=0;i<a.length;++i)
output = output + new String(a.toString())+"\n";
return output;
private static void quickSort(Comparable[] theArray,
int first, int last) {
// Sorts the items in an array into ascending order.
// Precondition: theArray[first..last] is an array.
// Postcondition: theArray[first..last] is sorted.
// Calls: partition.
int pivotIndex;
if (first < last) {
// create the partition: S1, Pivot, S2
pivotIndex = partition(theArray, first, last);
// sort regions S1 and S2
quickSort(theArray, first, pivotIndex-1);
quickSort(theArray, pivotIndex+1, last);
} // end if
} // end quickSort
private static int partition(Comparable[] theArray,
int first, int last) {
// Partitions an array for quicksort.
// Precondition: theArray[first..last] is an array;
// first <= last.
// Postcondition: Returns the index of the pivot element of
// theArray[first..last]. Upon completion of the method,
// this will be the index value lastS1 such that
// S1 = theArray[first..lastS1-1] < pivot
// theArray[lastS1] == pivot
// S2 = theArray[lastS1+1..last] >= pivot
// Calls: choosePivot.
// tempItem is used to swap elements in the array
Comparable tempItem;
// place pivot in theArray[first]
//choosePivot(theArray, first, last);
Comparable pivot = theArray[first]; // reference pivot
// initially, everything but pivot is in unknown
int lastS1 = first; // index of last item in S1
// move one item at a time until unknown region is empty
for (int firstUnknown = first + 1; firstUnknown <= last;
++firstUnknown) {
// Invariant: theArray[first+1..lastS1] < pivot
// theArray[lastS1+1..firstUnknown-1] >= pivot
// move item from unknown to proper region
if (theArray[firstUnknown].compareTo(pivot) < 0) {
// item from unknown belongs in S1
++lastS1;
tempItem = theArray[firstUnknown];
theArray[firstUnknown] = theArray[lastS1];
theArray[lastS1] = tempItem;
} // end if
// else item from unknown belongs in S2
} // end for
// place pivot in proper position and mark its location
tempItem = theArray[first];
theArray[first] = theArray[lastS1];
theArray[lastS1] = tempItem;
return lastS1;
} // end partition
// Given a new word, add it to the graph
public void addNode(String word) {
GraphNode node = new GraphNode(word);
if(graph.contains(node)){
JOptionPane.showMessageDialog(null,"Duplicate Word, operation terminated");
for(int i=0; i<graph.size(); ++i) {
if(isAnEdge((String)(((GraphNode)graph.get(i)).getVertex()),(String)(node.getVertex()))) {
EdgeNode e1 = new EdgeNode((String)node.getVertex(),1);
EdgeNode e2 = new EdgeNode((String)((GraphNode)graph.get(i)).getVertex(),1);
node.addEdge(e2);
((GraphNode)graph.get(i)).addEdge(e1);
graph.add(node);
public boolean deleteNode(String word) {
GraphNode node = new GraphNode(word);
EdgeNode n = new EdgeNode(word,1);
if(!graph.contains(node)) {
return false;
else {
for(int i=0; i<graph.size();++i) {
((GraphNode)graph.get(i)).getEdgeList().remove(n);
graph.remove(node);
return true;
public void save(String fileName) {
try {
PrintWriter output = new PrintWriter(new FileWriter("word.txt"));
for(int i=0; i< graph.size();++i) {
output.println(((GraphNode)graph.get(i)).getVertex());
output.close();
catch (IOException e) {
// given two word, find the ladder (using dijkstra's algorithm
// create a string for the ladder and return it
public String findLadder(String start,String end) {
String ladder = new String();
GraphNode sv = new GraphNode(start);
GraphNode ev = new GraphNode(end);
if(!graph.contains(sv)) {
JOptionPane.showMessageDialog(null,start + " not in graph");
return null;
if(!graph.contains(ev)) {
JOptionPane.showMessageDialog(null,end + " not in graph");
return null;
LinkedList distance = new LinkedList(((GraphNode)graph.get(graph.indexOf(sv))).getEdgeList());
LinkedList visited = new LinkedList();
visited.add(start);
LinkedList path = new LinkedList();
path.add(new PathNode(start,"****"));
for(int i=0; i<distance.size();++i) {
PathNode p = new PathNode((String)((EdgeNode)distance.get(i)).getKey(),start);
path.add(p);
while(!visited.contains(end)) {
EdgeNode min = findSmallest(distance,visited);
String v = (String)min.getVertex();
if(v.equals("****"))
return null;
visited.add(v);
// for(int i=0;i<graph.size();++i) {
// String u = (String)(((GraphNode)(graph.get(i))).getVertex());
GraphNode temp1 = new GraphNode(v);
int index = graph.indexOf(temp1);
LinkedList l = new LinkedList(((GraphNode)graph.get(index)).getEdgeList());
for(int i=0;i<l.size();++i)
String u = (String)(((EdgeNode)(l.get(i))).getVertex());
if(!visited.contains(u)) {
int du=999, dv=999, avu=999;
dv = min.getCost();
EdgeNode edge = new EdgeNode(u,1);
if(distance.contains(edge)) {
du = ((EdgeNode)(distance.get(distance.indexOf(edge)))).getCost();
GraphNode temp = new GraphNode(v);
GraphNode node = ((GraphNode)(graph.get(graph.indexOf(temp))));
LinkedList edges = node.getEdgeList();
if(edges.contains(edge)) {
avu = ((EdgeNode)(edges.get(edges.indexOf(new EdgeNode(u,1))))).getCost();
if( du > dv+avu) {
if(du == 999) {
distance.add(new EdgeNode(u,dv+avu));
path.add(new PathNode(u,v));
else {
((EdgeNode)(distance.get(distance.indexOf(u)))).setCost(dv+avu);
((PathNode)(path.get(path.indexOf(u)))).setEnd(v);
if(!path.contains(new PathNode(end,"")))
return null;
LinkedList pathList = new LinkedList();
for(int i=0;i<path.size();++i) {
PathNode n = (PathNode)path.get(path.indexOf(new PathNode(end,"****")));
if(n.getEnd().compareTo("****") != 0) {
pathList.addFirst(end);
n = (PathNode)path.get(path.indexOf(new PathNode(n.getEnd(),"****")));
end = n.getStart();
pathList.addFirst(start);
for(int i=0;i<pathList.size()-1;++i) {
ladder = ladder + ((String)(pathList.get(i))) + " --> ";
ladder = ladder + ((String)(pathList.get(pathList.size()-1)));
return ladder;
private EdgeNode findSmallest(LinkedList distance, LinkedList visited) {
EdgeNode min = new EdgeNode("****",999);
for(int i=0;i<distance.size();++i) {
String node = (String)(((EdgeNode)distance.get(i)).getVertex());
if(!visited.contains(node)) {
if(((EdgeNode)distance.get(i)).getCost()<min.getCost()) {
min = (EdgeNode)distance.get(i);
return min;
// class that represents nodes inserted into path set
private class PathNode {
protected String sv;
protected String ev;
public PathNode(String s,String e) {
sv = s;
ev = e;
public String getEnd() {
return ev;
public String getStart() {
return sv;
public void setEnd(String n) {
ev = n;
public boolean equals(Object o) {
return this.sv.equals(((PathNode)o).sv);
public String toString() {
return "("+sv+":"+ev+")";
thank you
let me fix my misstake which was point out by some one in here and thank you ofr do so because I'm new at this.
I have this file but I need to improve the code on some method. The methods are addNode, deleteNode, saveNode, findLader and are they anyway for me to iliminate the findsmallest method?
here is the code
import java.io.*;
import java.util.LinkedList;
import java.util.Stack;
import javax.swing.*;
public class Graph {
private LinkedList graph;
private BufferedReader inputFile;
public Graph() {
graph = new LinkedList();
// read the words from the given file
// create a GraphNode
// Add the node to the graph
public void createGraph(String fileName) throws IOException {
inputFile = new BufferedReader(
new InputStreamReader(new FileInputStream("word.txt")));
// Convert the linkedlist to an array 'a'
// sort the array 'a'
// create a string from all elements in 'a'
// return the string
public String printGraph() {
String output = new String();
// will contain String objects
// ... do some work with the list, adding, removing String objects
String[] a = new String[graph.size()];
graph.toArray(a);
// now stringArray contains all the element from linkedList
quickSort(a, 0, a.size() - 1);
for(int i=0;i<a.length;++i)
output = output + new String(a.toString())+"\n";
return output;
private static void quickSort(Comparable[] theArray,
int first, int last) {
// Sorts the items in an array into ascending order.
// Precondition: theArray[first..last] is an array.
// Postcondition: theArray[first..last] is sorted.
// Calls: partition.
int pivotIndex;
if (first < last) {
// create the partition: S1, Pivot, S2
pivotIndex = partition(theArray, first, last);
// sort regions S1 and S2
quickSort(theArray, first, pivotIndex-1);
quickSort(theArray, pivotIndex+1, last);
} // end if
} // end quickSort
private static int partition(Comparable[] theArray,
int first, int last) {
// Partitions an array for quicksort.
// Precondition: theArray[first..last] is an array;
// first <= last.
// Postcondition: Returns the index of the pivot element of
// theArray[first..last]. Upon completion of the method,
// this will be the index value lastS1 such that
// S1 = theArray[first..lastS1-1] < pivot
// theArray[lastS1] == pivot
// S2 = theArray[lastS1+1..last] >= pivot
// Calls: choosePivot.
// tempItem is used to swap elements in the array
Comparable tempItem;
// place pivot in theArray[first]
//choosePivot(theArray, first, last);
Comparable pivot = theArray[first]; // reference pivot
// initially, everything but pivot is in unknown
int lastS1 = first; // index of last item in S1
// move one item at a time until unknown region is empty
for (int firstUnknown = first + 1; firstUnknown <= last;
++firstUnknown) {
// Invariant: theArray[first+1..lastS1] < pivot
// theArray[lastS1+1..firstUnknown-1] >= pivot
// move item from unknown to proper region
if (theArray[firstUnknown].compareTo(pivot) < 0) {
// item from unknown belongs in S1
++lastS1;
tempItem = theArray[firstUnknown];
theArray[firstUnknown] = theArray[lastS1];
theArray[lastS1] = tempItem;
} // end if
// else item from unknown belongs in S2
} // end for
// place pivot in proper position and mark its location
tempItem = theArray[first];
theArray[first] = theArray[lastS1];
theArray[lastS1] = tempItem;
return lastS1;
} // end partition
// Given a new word, add it to the graph
public void addNode(String word) {
GraphNode node = new GraphNode(word);
if(graph.contains(node)){
JOptionPane.showMessageDialog(null,"Duplicate Word, operation terminated");
for(int i=0; i<graph.size(); ++i) {
if(isAnEdge((String)(((GraphNode)graph.get(i)).getVertex()),(String)(node.getVertex()))) {
EdgeNode e1 = new EdgeNode((String)node.getVertex(),1);
EdgeNode e2 = new EdgeNode((String)((GraphNode)graph.get(i)).getVertex(),1);
node.addEdge(e2);
((GraphNode)graph.get(i)).addEdge(e1);
graph.add(node);
public boolean deleteNode(String word) {
GraphNode node = new GraphNode(word);
EdgeNode n = new EdgeNode(word,1);
if(!graph.contains(node)) {
return false;
else {
for(int i=0; i<graph.size();++i) {
((GraphNode)graph.get(i)).getEdgeList().remove(n);
graph.remove(node);
return true;
public void save(String fileName) {
try {
PrintWriter output = new PrintWriter(new FileWriter("word.txt"));
for(int i=0; i< graph.size();++i) {
output.println(((GraphNode)graph.get(i)).getVertex());
output.close();
catch (IOException e) {
// given two word, find the ladder (using dijkstra's algorithm
// create a string for the ladder and return it
public String findLadder(String start,String end) {
String ladder = new String();
GraphNode sv = new GraphNode(start);
GraphNode ev = new GraphNode(end);
if(!graph.contains(sv)) {
JOptionPane.showMessageDialog(null,start + " not in graph");
return null;
if(!graph.contains(ev)) {
JOptionPane.showMessageDialog(null,end + " not in graph");
return null;
LinkedList distance = new LinkedList(((GraphNode)graph.get(graph.indexOf(sv))).getEdgeList());
LinkedList visited = new LinkedList();
visited.add(start);
LinkedList path = new LinkedList();
path.add(new PathNode(start,"****"));
for(int i=0; i<distance.size();++i) {
PathNode p = new PathNode((String)((EdgeNode)distance.get(i)).getKey(),start);
path.add(p);
while(!visited.contains(end)) {
EdgeNode min = findSmallest(distance,visited);
String v = (String)min.getVertex();
if(v.equals("****"))
return null;
visited.add(v);
// for(int i=0;i<graph.size();++i) {
// String u = (String)(((GraphNode)(graph.get(i))).getVertex());
GraphNode temp1 = new GraphNode(v);
int index = graph.indexOf(temp1);
LinkedList l = new LinkedList(((GraphNode)graph.get(index)).getEdgeList());
for(int i=0;i<l.size();++i)
String u = (String)(((EdgeNode)(l.get(i))).getVertex());
if(!visited.contains(u)) {
int du=999, dv=999, avu=999;
dv = min.getCost();
EdgeNode edge = new EdgeNode(u,1);
if(distance.contains(edge)) {
du = ((EdgeNode)(distance.get(distance.indexOf(edge)))).getCost();
GraphNode temp = new GraphNode(v);
GraphNode node = ((GraphNode)(graph.get(graph.indexOf(temp))));
LinkedList edges = node.getEdgeList();
if(edges.contains(edge)) {
avu = ((EdgeNode)(edges.get(edges.indexOf(new EdgeNode(u,1))))).getCost();
if( du > dv+avu) {
if(du == 999) {
distance.add(new EdgeNode(u,dv+avu));
path.add(new PathNode(u,v));
else {
((EdgeNode)(distance.get(distance.indexOf(u)))).setCost(dv+avu);
((PathNode)(path.get(path.indexOf(u)))).setEnd(v);
if(!path.contains(new PathNode(end,"")))
return null;
LinkedList pathList = new LinkedList();
for(int i=0;i<path.size();++i) {
PathNode n = (PathNode)path.get(path.indexOf(new PathNode(end,"****")));
if(n.getEnd().compareTo("****") != 0) {
pathList.addFirst(end);
n = (PathNode)path.get(path.indexOf(new PathNode(n.getEnd(),"****")));
end = n.getStart();
pathList.addFirst(start);
for(int i=0;i<pathList.size()-1;++i) {
ladder = ladder + ((String)(pathList.get(i))) + " --> ";
ladder = ladder + ((String)(pathList.get(pathList.size()-1)));
return ladder;
private EdgeNode findSmallest(LinkedList distance, LinkedList visited) {
EdgeNode min = new EdgeNode("****",999);
for(int i=0;i<distance.size();++i) {
String node = (String)(((EdgeNode)distance.get(i)).getVertex());
if(!visited.contains(node)) {
if(((EdgeNode)distance.get(i)).getCost()<min.getCost()) {
min = (EdgeNode)distance.get(i);
return min;
// class that represents nodes inserted into path set
private class PathNode {
protected String sv;
protected String ev;
public PathNode(String s,String e) {
sv = s;
ev = e;
public String getEnd() {
return ev;
public String getStart() {
return sv;
public void setEnd(String n) {
ev = n;
public boolean equals(Object o) {
return this.sv.equals(((PathNode)o).sv);
public String toString() {
return "("+sv+":"+ev+")";
}thank you
Similar Messages
-
Need help in the code for updating a record ( conditional update)
all set
Edited by: 871431 on Jul 9, 2011 6:30 PM871431 wrote:
Hi
I am looking to update a table which contains approved & unapproved records, for that date & fund combination it should allow only one unapproved record.
what I did is check if the record is U if the incoming value is Unapproved for that fund & date combination raise error, but if I need to update that Unapproved record it raises error....so I need to update that record, and raise error if trying to insert another unapproved record.
Hope I am clear....Not clear for me
Help needed plsPlease realize & understand that everyone here speaks SQL
please post DDL for table
please provide sample/test data & then explain using actual test data what the results should be & why -
Need help with the code...
The program should accept two inputs from user in form of military time for example (1245). Then it should calculate and display the difference.
For some reason it displays 0's...
Please help.
Thanks.
public class TimeInterval
private int firstHour;
private int firstMin;
private int secondHour;
private int secondMin;
//Constructor
public TimeInterval(String first, String second)
String h1 = first.substring(0,1);
int h2 = Integer.parseInt(h1);
firstHour = h2;
//firstHour = Integer.parseInt(first.substring(0,1));
String m1 = second.substring(2,3);
int m2 = Integer.parseInt(m1);
firstMin = m2;
//firstMin = Integer.parseInt(second.substring(2,3));
String hh1 = first.substring(0,1);
int hh2 = Integer.parseInt(hh1);
secondHour = hh2;
//secondHour = Integer.parseInt(first.substring(0,1));
String mm1 = second.substring(2,3);
int mm2 = Integer.parseInt(mm1);
secondMin = mm2;
//secondMin = Integer.parseInt(second.substring(2,3));
//Methods
public int getHours()
int HourDifference = secondHour - firstHour;
return HourDifference;
public int getMinutes()
int MinutesDifference = secondMin - firstMin;
return MinutesDifference;
import java.util.Scanner;
public class TimeIntervalTest
public static void main(String[] args)
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the First time now:");
String hr = scanner.next();
System.out.print("Enter the Second time now:");
String mn = scanner.next();
System.out.println(hr);
System.out.println(mn);
TimeInterval timeDifference = new TimeInterval(hr, mn);
System.out.println(timeDifference.getHours());
System.out.println(timeDifference.getMinutes());
}I can't say I understand your code, but for a starter, I think you are misunderstanding method substring:
public class StringExample {
public static void main(String[] args) {
String first = "2345";
String h1 = first.substring(0,1);
System.out.println(h1);
} -
Urgent-Need help with the code.
Hi gurus,
I am trying to write a code where i am populating the ZZorg1,ZZorg2 and ZZorg3 in VBRP tableto 2LIS_13_VDITM.
WHEN '2LIS_13_VDITM'.
DATA: X_T_DATA Like MC13VD0ITM.
Loop at C_T_DATA into X_T_DATA.
Select Single ZZSORG1 into X_T_DATA-ZZSORG1
ZZSORG2 into X_T_DATA-ZZSORG2
ZZSORG3 into X_T_DATA-ZZSORG3
FROM VBRP
WHERE VBELN = X_T_DATA-VBELN
AND POSNR = X_T_DATA-POSNR.
MODIFY C_T_DATA from X_T_DATA.
ENDLOOP.
I am getting the following error when running a error check.
"ZZSORG2 INTO X_T_DATA-ZZSORG2" is not expected.Can anybody let me know what i am doing wrong as i new to ABAP.
Thanks in advance
Resolved it,thanks
Message was edited by:
sap noviceResolved it
-
Need help in transcation code ime0
I need help in transaction code ime0. I mean to say what is this TCode doing? What different Drill-down program means? Where I can use this report?
Regards,
SubhasishHi
Please check the link for help
<a href="http://help.sap.com/saphelp_47x200/helpdata/EN/5c/8db33f555411d189660000e829fbbd/frameset.htm">CA - Drilldown Reporting</a>
Hope it helps
Anirban -
Can we Improve the code Further
Hi All i 've the following code.
Can we improve the code further PROBABLY BY USING FORALL OR VARRAYS?
(MY ORACLE VERSION IS 10.2).
Thanks in Advance
CREATE OR REPLACE PROCEDURE PR_INS_TEM_EMP(M_USER_DEFINED_VALUE NUMBER,
P_ESAL NUMBER,
P_EDEPTNO NUMBER,
P_USER_ID VARCHAR2) IS
CURSOR C1 IS
SELECT ENO,ENAME FROM EMP WHERE ROWNUM <= M_USER_DEFINED_VALUE;
TYPE T_EMP IS TABLE OF C1%TYPE;
M_T_EMP T_EMP;
BEGIN
IF C1%ISOPEN THEN
CLOSE C1;
END IF;
OPEN C1;
FETCH C1 BULK COLLECT INTO M_T_EMP;
CLOSE C1;
FOR I IN 1..M_T_EMP.LAST LOOP
INSERT INTO TEMP_EMP(ENO,
ENAME,
ESAL,
EDEPT_NO,
USER_ID
(M_T_EMP(I).ENO,
M_T_EMP(I).ENAME,
P_ESAL,
P_EDEPTNO,
P_USER_ID
END LOOP;
END;Hello, why use a cursor at all, why not:
CREATE OR REPLACE PROCEDURE PR_INS_TEM_EMP(M_USER_DEFINED_VALUE NUMBER) IS
BEGIN
INSERT /*+ APPEND */ INTO TEMP_EMP(ENO,ENAME,ESAL,EDEPT_NO,USER_ID)
SELECT ENO,ENAME
FROM EMP
WHERE ROWNUM <= M_USER_DEFINED_VALUE;
END;And you are declaring but never using P_ESAL NUMBER,P_EDEPTNO NUMBER & P_USER_ID VARCHAR2. So why have them?
By the way, putting {noformat}{noformat} before and after your code will help the readability no end. -
I need to retrieve the code I was given to activate my creative suite design & web premium.
PLEASE can someone help me. I need to retrieve the code I was given to activate my creative suite design & web premium. I have got a new mac and it is only saying I have a 30 day trial.
Sign in, activation, or connection errors | CS5.5 and later
Find your serial number quickly
Mylenium -
I need help with the Quote applet.
Hey all,
I need help with the Quote applet. I downloaded it and encoded it in the following html code:
<html>
<head>
<title>Part 2</title>
</head>
<body>
<applet codebase="/demo/quote/classes" code="/demo/quote/JavaQuote.class"
width="300" height="125" >
<param name="bgcolor" value="ffffff">
<param name="bheight" value="10">
<param name="bwidth" value="10">
<param name="delay" value="1000">
<param name="fontname" value="TimesRoman">
<param name="fontsize" value="14">
<param name="link" value="http://java.sun.com/events/jibe/index.html">
<param name="number" value="3">
<param name="quote0" value="Living next to you is in some ways like sleeping with an elephant. No matter how friendly and even-tempered is the beast, one is affected by every twitch and grunt.|- Pierre Elliot Trudeau|000000|ffffff|7">
<param name="quote1" value="Simplicity is key. Our customers need no special technology to enjoy our services. Because of Java, just about the entire world can come to PlayStar.|- PlayStar Corporation|000000|ffffff|7">
<param name="quote2" value="The ubiquity of the Internet is virtually wasted without a platform which allows applications to utilize the reach of Internet to write ubiquitous applications! That's where Java comes into the picture for us.|- NetAccent|000000|ffffff|7">
<param name="space" value="20">
</applet>
</body>
</html>When I previewed it in Netscape Navigator, a box with a red X appeared, and this appeared in the console when I opened it:
load: class /demo/quote/JavaQuote.class not found.
java.lang.ClassNotFoundException: .demo.quote.JavaQuote.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: \demo\quote\JavaQuote\class.class (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
Exception in thread "Thread-4" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)What went wrong? and how can I make it run correct?
Thanks,
Nathan PinnoJavaQuote.class is not where your HTML says it is. That is at the relative URL "/demo/quote/".
-
I need help with this code error "unreachable statement"
the error_
F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
int index;
^
F:\Java\Projects\Tools.java:71: missing return statement
}//end delete method
^
F:\Java\Projects\Tools.java:86: missing return statement
}//end getrecod
^
3 errors
import java.util.*;
import javax.swing.*;
import java.awt.*;
public class Tools//tool class
private int numberOfToolItems;
private ToolItems[] toolArray = new ToolItems[10];
public Tools()//array of tool
numberOfToolItems = 0;
for(int i = 0; i < toolArray.length; i++)//for loop to create the array tools
toolArray[i] = new ToolItems();
}//end for loop
}//end of array of tools
public int search(int id)//search mehtod
int index = 0;
while (index < numberOfToolItems)//while and if loop search
if(toolArray[index].getID() == id)
return index;
else
index ++;
}//en while and if loop
return -1;
}//end search method
public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
if(numberOfToolItems >= toolArray.length)
return 0;
int index;
index = search(id); <-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------HERE
if (index == -1)
toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
numberInStock ++;
return 1;
}//end if index
}//end if toolitem array
return -1;
}//end insert method
public int delete(/*int id*/)//delete method
}//end delete method
public void display()//display method
for(int i = 0; i < numberOfToolItems; i++)
//toolArray.display(g,y,x);
}//end display method
public String getRecord(int i)//get record method
// return toolArray[i].getName()+ "ID: "+toolArray[i].getID()
}//end getrecod
}//end class
Edited by: ladsoftware on Oct 9, 2009 6:08 AM
Edited by: ladsoftware on Oct 9, 2009 6:09 AM
Edited by: ladsoftware on Oct 9, 2009 6:10 AM
Edited by: ladsoftware on Oct 9, 2009 6:11 AMladsoftware wrote:
Subject: Re: I need help with this code error "unreachable statement"
F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
int index;
^
F:\Java\Projects\Tools.java:71: missing return statement
}//end delete method
^
F:\Java\Projects\Tools.java:86: missing return statement
}//end getrecod
^
3 errorsThe compiler is telling you exactly what the problems are:
public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
if(numberOfToolItems >= toolArray.length)
return 0; // <<== HERE you return, so everyting in the if block after this is unreachable
int index;
index = search(id); //< -----------------------------------------------------------------------------------------------------------------HERE
if (index == -1)
toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
numberInStock ++;
return 1;
}//end if index
}//end if toolitem array
return -1;
}//end insert method
public int delete(/*int id*/)//delete method
// <<== HERE where is the return statement?
}//end delete method
public String getRecord(int i)//get record method
// return toolArray.getName()+ "ID: "+toolArray[i].getID() <<== HERE you commented out the return statement
}//end getrecod
}//end class -
I need help with my code..
hi guys. as the subject says I need help with my code
the Q for my code is :
write a program that reads a positive integer x and calculates and prints a floating point number y if :
y = 1 ? 1/2 + 1/3 - ? + 1/x
and this is my code
This program that reads a positive integer x and calculates
and prints a floating point number y if :
y = 1 - 1/2 + 1/3 - ? + 1/x
import java.util.Scanner; // program uses class Scanner
class Sh7q2
// main method begins execution of Java application
public static void main( String args[] )
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
int i = 1; // i is to control the loop
int n = 2; // n is suppose to control the number sign
int x; // a positive integer entered by the user
int m;
System.out.println("Enter a positive integer");
x = input.nextInt();
do
m = (int) Math.pow( -1, n)/i;
System.out.println(m);
n++;
i++;
while ( m >= 1/x );
} // end method main
} // end class Sh7q2 when I compile it there is no error
but in the run it tells me to enter a positive integer
suppose i entered 5
then the result is 1...
can anyone tell me what's wrong with my codeThis program that reads a positive integer x and calculates
and prints a floating point number y if :
y = 1 - 1/2 + 1/3 - ? + 1/x
import java.util.Scanner; // program uses class Scanner
class Sh7q2
// main method begins execution of Java application
public static void main( String args[] )
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
int i = 1; // i is to control the loop
int n = 1; // n is suppose to control the number sign
int x; // a positive integer entered by the user
double m;
int a = 1;
double sum = 0;
System.out.println("Enter a positive integer");
x = input.nextInt();
for ( i = 1; a <= x; i++)
m = Math.pow( -1, n+1)/i;
sum = sum + m;
n++;
a++;
System.out.print("y = " + sum);
} // end method main
} // end class Sh7q2is it right :S -
I need to cancel the code that I redeem and restart the code
I went to use another email and pass word to redeem my gift card. I did not relize I could use my email. so I need to have the code canceled from the [email protected] so I can use it on my [email protected] can some one help me. this is my first time using itunes
Click here and request assistance.
(63314) -
I just created an iCloud email and I want to use that email for my iTunes account as well. I need help switching the old apple ID because I do not remember anything associated with that email and I don't know the security questions or the login for that old email.
You cannot do that. The AppleID you used to create the iCloud account is an active primary email address. The email address you created with the iCloud account is also an active primary email address (all Apple domain email address automatically become AppleIDs as well). You cannot replace the primary email address on one active AppleID with the primary email address on another, active AppleID.
You can use your iCloud email/AppleID with iTunes, but it will be a separate account, so all your previous purchases remain tied to the other AppleID you have.
I don't understand your statement that you could not remeber your old AppleID password, as you would have had to use it to create the iCloud account in the first place (the first step of creating the iCloud account required you to login with your existing AppleID and password)? -
Need help with the Vibrance adjustment in Photoshop CC 2014.
Need help with the Vibrance adjustment in Photoshop CC 2014.
Anytime I select Vibrance to adjust the color of an image. The whole image turns Pink in the highlights when the slider is moved from "0" to - or + in value. Can the Vibrance tool be reset to prevent this from happening? When this happens I cn not make adjustments...just turns Pink.
Thanks,
GDThank you for your reply.
Yes, that does reset to “0” and the Pink does disappear.
But as soon as I move the slider +1 or -1 or higher the image turns Pink in all of the highlights again, rather than adjusting the overall color.
GD
Guy Diehl web: www.guydiehl.com | email: [email protected] -
I need help with the iPad Remote app to connect to apple TV 2
I need help with the iPad Remote app to connect to apple TV 2 I have the app already on my ipad and when I open it only shows my itunes library and not the small black Apple TV 2 icon! How do i fix this and i know it's something
Get the manual at http://manuals.info.apple.com/en_US/AppleTV_SetupGuide.pdf
Cheers, Tom -
Need help accessing the router web page. I have been tol...
Need help accessing the router web page. I have been told my router is acting like a switch and the IP address is not in the proper range. I have tried reseting the router (hold for 30 sec and unplug for 5 mins). Didn't work.
thanksWhat router are you using? Almost all Linksys routers use 192.168.1.1 as the default local IP address, but there is at least one that uses 192.168.16.1 , namely the WTR54GS (not the WRT54GS).
You need to try again to reset the router to factory defaults.
To reset your router to factory defaults, use the following procedure:
1) Power down all computers, the router, and the modem, and unplug them from the wall.
2) Disconnect all wires from the router.
3) Power up the router and allow it to fully boot (1-2 minutes).
4) Press and hold the reset button for 30 seconds, then release it, then let the router reset and reboot (2-3 minutes).
5) Power down the router.
6) Connect one computer by wire to port 1 on the router (NOT to the internet port).
7) Power up the router and allow it to fully boot (1-2 minutes).
8) Power up the computer (if the computer has a wireless card, make sure it is off).
9) Try to ping the router. To do this, click the "Start" button > All Programs > Accessories > Command Prompt. A black DOS box will appear. Enter the following: "ping 192.168.1.1" (no quotes), and hit the Enter key. You will see 3 or 4 lines that start either with "Reply from ... " or "Request timed out." If you see "Reply from ...", your computer has found your router.
10) Open your browser and point it to 192.168.1.1. This will take you to your router's login page. Leave the user name blank (note: a few Linksys routers have a default user name of "admin" (with no quotes)), and in the password field, enter "admin" (with no quotes). This will take you to your router setup page. Note the version number of your firmware (usually listed near upper right corner of screen). Exit your browser.
If you get this far without problems, try the setup disk (or setup the router manually, if you prefer), and see if you can get your router setup and working.
If you cannot get "Reply from ..." in step 9 above, your router is dead.
If you get a reply in step 9, but cannot complete step 10, then either your router is dead or the firmware is corrupt. In this case, use the Linksys tftp.exe program to try to reload your router with the latest firmware. After reloading the firmware, repeat the above procedure starting with step 1.
If you need additional help, please state your ISP, the make and model of your modem, your router's firmware version, and the results of steps 9 and 10. Also, if you get any error messages, copy them exactly and report back.
Please let me know how things turn out for you.
Message Edited by toomanydonuts on 01-21-2008 04:40 AM
Maybe you are looking for
-
I am updating to a new computer, old system was Windows XP my new computer is Windows 7. Can I save my bookmarks and bookmark toolbar from old XP system to install on my new Windows 7 system ?
-
Since updating to iOS 7.1.1 my iPhone 4S (16GB) is no longer compatible with the Sony audio dock. How can I fix this ? it was working before updating my phone. Thanks for your reply
-
Running the newest version of FF, Windows XP. Everything was working beautifully until I downloaded the ActiveX plugin when prompted a few days ago. Then the sound on YouTube got borked--I can see the videos just fine, but no sound at all. I've tried
-
I tried to open my library and it said the library had been corrupted and saved as a damaged file. When it finally opened thousands of songs were missing. I can't re-download and then re-import each of these songs. I tried to repair the library after
-
Recently during BIOS upgrade my Windows 8.1 installation for Aspire E5-411G-P717 notebook was damaged and recovery would not be allowed because the windows install partition was blocked. So, I resorted to the only known way to recover by using GPARTE