I have to fetch only the book name attribute and use it for display .However say for example ,I have got the list of Books ie(C#,Oracle,Archius) ,passing this value to a method should return me an array of URL nodes value within it.
The idea is to display the book names in a list and then on user selection , corresponding URL needs to be fetched.
Was able to get the loop for traversing the nodes
[java=code]
NodeList nodeList = document.getDocumentElement().getElementsByTagName ("Book");
for (int i = 0; i < nodeList.getLength(); i++) {...
[java=code]
So
a) Display the BookNames
b) Get the corresponding URL's for the particular book if I pass the Bookname
TL,DR: observe the nodes just below, that is the data each node in the link list contains. How do I iterate through the entire list to reach the last element (H), so I can add an element right after it?
So I have 4 nodes doubly linked with two dummy nodes for head and tail:
Ok, so since the list only contains 8 elements that are not null, its size is actually 8 correct? So now lets say I have an add method that has
add(E item) and inserts the item at the end of the list. So I can get to the last node with tail.previous(), but then how do I iterate to the end so I can add the item after the last item in the list (H). I guess I don't know how you only access one nodes data when that data is an array with empty spaces.
Here is the entire Node code:
Also, I can't just iterate through the whole thing because I am not supposed to. I am supposed to just find the right node and iterate through that only.how to maneuver around a linked list containing nodes where each node contains an array.
/** * Node class that makes up a DoublingList. Feel free to add methods / * constructors / variables you might find useful in here. */ public class Node<E> {
/** * The node that comes after this one in the list
What the program must do is to parse the string-declared two-dimensional array for the program to compute the student's scores in their quizzes, but I'm having difficulty in anything with Parsing so I don't know what will be the appropriate codes.
Error: incompatible types: String[][] cannot be converted to int[][]
import java.io.*; public class Quiz3{ public static void main(String[]args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String [][]StudQuiz = new String [5][4];
[Code] ....
How am I able to compute the average of the score if the data that is needed to be computed is in the string-declared array?
public void add(int d){ listNode l = new listNode (d, null); l.next = first; first= l; } public list Sum2List (list l1, list l2){ //variables int sum;
[Code] .....
But I have a problem in my first listNode where it ll be pointing to null, thus in the sum2List method the program checks the while condition into false and doesn't go through the loop.
I want to use a method, which takes for example an int and also returns an integer. For example, if the the given integer is strong return a, if it is notstrong return b. How would you write that in a Code?
I want to use that in a more general way. I want to give a method mlong the value X of the type date and let it return an int. Type date consists of 3 int, one of them is the int month.
mlong should return an int depending on the X.moth. at the moment my code looks like this:
// File1: public class date { public int day; public int month; public int year; }
// File 2: public class monthlength { public int mlong(date X) { int t; t = X.month; if (t == 1 || t == 3 || t == 5 || t == 7 || t == 8 || t == 10 || t == 12) { return 31; } if(t == 4 || t == 6 || t == 9 || t == 11) {return 30;} } }
I want to return values from arrays to the main and the problem is i cant use my variables from my constructor, I use new variables in my functions and i know this is no good, when I used the variables from the constructor in my function. I have a compilations errors,also i want to create un object in main and with this object i want to call the functions.
Java Code:
package javaapplication4; import java.util.Scanner; public class JavaApplication4 { public static int[] MyInt; public static double[] MyDouble; public static String[] MyString; public static char[] MyChar;
[Code] .....
The code is working when i run it and i have the right result in my screen but i know this is all wrong with the variables.
I am getting these errors with this code, I can not figure why this error is occuring.
what is the issue with this code?
Java Code: package ABC; import java.util.ArrayList; import java.util.Scanner; public class GetInputFromUser { private ArrayList<String> name = new ArrayList<String>();
I need to return all the object name of one class in an array. I have a class named country, and other classes with athletes and medals etc. I need to do a method that list an array with all the countries that participate, so all the objects created with the class country (i.e canada.country, usa.country, etc). Is there a way I can retrieve them?
I need to return all the object name of one class in an array. I have a class named country, and other classes with athletes and medals etc. I need to do a method that list an array with all the countries that participate, so all the objects created with the class country (i.e canada.country, usa.country, etc). Is there a way I can retrieve them?
I need to design a class named Location for locating a maximal value and its location in a two-dimensional array. The class should contain public data fields row, column, and maxValue that store the maximal value and its indices in a two dimensional array with row and column as int type and maxValue as double type.
I need to write the following method that returns the location of the largest element in a two-dimensional array: public static location locateLargest(double[][] a)
The return value is an instance of Location. Write a test program that prompts the user to enter a two-dimensional array and displays the location of the largest element in the array.
Here is what i get when I run
Enter the number of rows and columns of the array: 3 4 Enter the array: 23.5 35 2 10 4.5 3 45 3.5 35 44 5.5 9.6 The location of the largest element is at 00 The location of the largest element is at 01
But I need it to display this instead.
Enter the number of rows and columns of the array: 3 4 Enter the array: 23.5 35 2 10 4.5 3 45 3.5 35 44 5.5 9.6 The location of the largest element is 45 at (1,2)
public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Number of rows and columns: "); int row = input.nextInt(); int col = input.nextInt();
[Code] ....
Enter the number of rows and columns of the array: 3 4 Enter the array: 23.5 35 2 10 4.5 3 45 3.5 35 44 5.5 9.6 The location of the largest element is at 00 The location of the largest element is at 01
I need it to display this instead.
Enter the number of rows and columns of the array: 3 4 Enter the array: 23.5 35 2 10 4.5 3 45 3.5 35 44 5.5 9.6 The location of the largest element is 45 at (1,2)
I am trying to understand the following code.This return statement should actually return the char at myArray[index] first, then increments the index afterwords correct?
I have attempted on my own many times but I am not getting any closer to a solution.
/**
* Returns a SmartArray with eight values. The values are the values stored in the 8 neighbors of the array cell at the given location in the Smart2DArray.
* Start with the neighbor to the "north" of the given cell and proceed clockwise, using -1 as the value if the neighboring cell is outside the Smart2DArray.
For example, if the array is: 1 2 3 4 5 6 7 8 9
neighbors(1, 1) should return a SmartArray with the values: 2 3 6 9 8 7 4 1 in that order.
neighbors(2,1) should return a SmartArray with the values: 3 -1 -1 -1 9 8 5 2 in that order.
*/ public SmartArray neighbors (int col, int row) { }
We have an application running successfully where we fetch the weight of product currently on Production Line using Java.
All the products on line belong to same order and are of same type. User at beginning enter the type of product and starts the production line.
Proposed new process: Now client want that multiple type of product can belong to same production order. i.e. on a production line different type of products can come one after other. So we should now fetch the type of product also.
The Question : what are different possibilities in which we can find the type of product. Can java fetch color of a box ? If we use scanner on line that scans the product and sends the color information to Java.
Above is just a possibility. Can there be any other parameters that Java can use to differentiate in type of product ?
Currently we are clueless. What ever are the possibilities in Java we can propose the same to client. Even if that requires additional hardware.
I am having an issue with a parallel array that I created that returns array values based on an input. The code only works for the first four array locations just fine. The remaining values are not found. I thought it might be a memory allocation issue with the array size, I tried to dimension the array, however, using the Eclipse editor get errors.
import java.util.*; import javax.swing.JOptionPane; public class StudentIDArray { static String[] studentNum = new String[] {"1234", "2345", "3456", "4567", "5678", "6789", "7890", "8901", "9012", "0123"}; static String[] studentName = new String[]
I'm trying to return an array back to main. The array returned to main should contain the reversed random numbers array. I believe I have the array correctly reversed within the 'reverseArray' method. I'm trying to send this array back to main, but it appears to contain empty data (a bunch of zeros).
Java Code:
class ArrToMain { public static void main(String[] args) { final int NUMBER_OF_ELEMENTS = 1000; double[] numbers = new double [NUMBER_OF_ELEMENTS]; //Invoke initialize method initialize(numbers);
Assignment: Given an array of scores sorted in increasing order, return true if the array contains 3 adjacent scores that differ from each other by at most 2, such as with {3, 4, 5} or {3, 5, 5}.
public boolean scoresClump(int[] scores) { for (int i = 0; i < scores.length; i++) { int a = scores[i]; int b = scores[i + 1]; int c = scores[i + 2]; if (Math.abs(b-a) + Math.abs (c-b) <=2) return true; } return false; }
I got it right for some of the input, but not one of them. I tried to use the for loop and if statement on a specific input that I got wrong:
I suspect it has something to do with the for loop, but I don't see the problem with it. It should work, shouldn't it? But anyway, here is the error for {4,5,8} :
If I change the servlet and have "request.getRequestDispatcher("/pages/ViewCompletedWWDocs.jsp").forward(request, response);" un commented, I get exception "java.lang.IllegalStateException: Cannot forward a response that is already committed".
The program contains username and password which on submission checks with the database if the details entered are right or wrong....on right details it Displays Welcome (name) and (lastname) parameters from database.
I am trying to build an address book, and I started from what i know how to do.
public class Persona { String nome; String indirizzo; int cellulare; public Persona(String nom, String ind, int cel) { nome = nom; indirizzo = ind; cellulare = cel;
[code].....
Now I would like the program to take a string I insert on command line (for example java Cerca"Robert Baratheon") and compare it to the nome field of every Persona in the address book.
Question - Given an specific integer and an array of integers, find and remove all occurrences of the given integer and return an amended array. I solved it. Here is my solution -