32,199 Topics
| |
import java.util.*; public class LinkedListDemo { public static void main(String[] args) { LinkedList link=new LinkedList(); link.add("a"); link.add("b"); link.add(new Integer(10)); System.out.println("The contents of array is" + link); System.out.println("The size of an linkedlist is" + link.size()); link.addFirst(new Integer(20)); System.out.println("The contents of array is" + link); System.out.println("The size of an linkedlist is" + … | |
i am create animation in japplet and i want to know if iam using paint method and draphics2d the right way. public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; g2d.fillRect(x, y, width, height); //player }/** end of paint method ***/ another question i had was in run … | |
I am trying to sort a certain amount of integers. I have an error in my code. The code is below as well as my error message. Any suggestions of how to fix this? I believe it has to do with it being primitive data rather than an object? `public … | |
A so-called “star number”, s, is a number defined by the formula: s = 6n(n-1) + 1 where n is the index of the star number. Thus the first six (i.e. for n = 1, 2, 3, 4, 5 and 6) star numbers are: 1, 13, 37, 73, 121, 181 … | |
In the last line of this method I am getting a missing return statement error, and I cannot figure out why. Any ideas? public static int parameter(int g){ Scanner console=new Scanner(System.in); String hint=console.next(); if(hint.equals("low")){ g=(g/2)+g; return g; }else if(hint.equals("high")){ g=(g/2); return g; }else if(hint.equals("correct")){ g=g; return g; } } | |
I'm having a weird problem where programs I write in Netbeans compile and run fine in the IDE, but when I try to run it from the command line, it finds errors and won't compile. A class file in the same directory that my main class needs to instantuate and … | |
I have a person class public class Person implements Comparable<Person> { //Instance Variables private String firstName; private String lastName; private int age; private char gender; private String ssn; // This is the constructor of the class Person public Person(String firstName, String lastName, int age, char gender, String ssn) { this.firstName … | |
Good day. I am trying to construct a mailto: url that will include the specific domain name or if possible the previous url from which a mail is sent from. I want to use this as an error report so that when an error is encountered by a person browsing … | |
Hello guys, I've been working on a game in Java, it doesn't use any third party libraries so everything was made from scratch, I was wondering if anyone was interested in helping me bring it to the next level. The game is going to be essentially a mix of Castlevania/Dark … | |
import java.util.Scanner; public class array_Project { int index; Scanner scan=new Scanner(System.in); System.out.println("Enter index number"); int[]Project={10,15,20,25,30,35,40,45,50,55}; } public class array2 { switch (int index) { case 1: if(index=0) { System.out.print(Project[0]); } break; case 2: if(index=1) { System.out.print(Project[1]); } break; case 3: if(index=2) { System.out.print(Project[2]); } break; case 4: if(index=3) { System.out.print(Project[3]); … | |
Guys, I really need your help. I have a Project about any systems activities related to java Program and I choose Mini Search Engine. Can you please Help me of how to use Class and Objects cause I'm about to use them in my source code. thanks. | |
public static int f (int []a, int []b,int []c) { final int N=a.length; int j, k=0, g=0, t=0 ; for(int i=0;i<N;i++) { for (j=0;j<N;j++) if (b[j]==a[i]) break; if (j==N) { c[t]=a[i]; if (g==0 || c[t]>k) { k=c[t]; g=1; } t++; } } return k; | |
Hi, I have a json_encoded array that comes out like this `{"y":33,"customTooltip":"BOK"},{"y":61,"customTooltip":"DRFlytt"},`... I need it to come out without the quotes surrounding the y and the customTooltip and singlequotes around the last value like this `{y:33,customTooltip:'BOK'},{y:61,customTooltip:'DR'},` Is this possible or should I find another approach? I derive the array like … | |
| |
I have an assignment to create 2 arrays. One holding Student names, one holding their grades. They then have to be sorted using BubbleSort, so that their grades are in descending order. I have created the first part of it, that allows me to put in their grades, and I … | |
how can i deleting an element in an array, then replace it with to 0 the move 0 to the last element??? | |
hey guys, can you suggest a good java compiler for me? i had eclipse, but it literally FELL APART. thanks, almond joy | |
'm new to Java and please try to explain to me. I am developing a game using slick2d and I'm making so called a shop.class and a player.class The shop class should add medkits to the player class. I have been making so many test on it even testing if … | |
I'm just curious about the use of frames/panels etc. What's are your general practices and why? Single main JFrame with multiple internal then toggling visibility of panels within? Just starting with swing and rather curious how other people implement them. | |
tickets consist of four colours: green, blue , red, and white. each ticket has an associated price: green cost €5, blue cost€10, red cost€20, white cost€30. write an enumerated class Ticket that has a toString method that pretty prints it and a getCost method that returns its cost. | |
Dear all, I have following code and i want to write elements of array in single string(merge with ,) , in between all the values. like a[0] = "hi" a[1] = "hello" a[2] = 1 a[0] = "get" a[1] = "post" a[2] = 2 a[3] = 45 then i want … | |
i know java c and c++ but i like java just because it was the first language i learned. i ask alot of people and they all seem to say "make game in c++" or "not a good idea to make games in java". what you guys think? should i … | |
import javax.vecmath.*; import com.sun.j3d.utils.universe.*; import javax.media.j3d.*; import com.sun.j3d.utils.behaviors.vp.*; import javax.swing.JFrame; import com.sun.j3d.loaders.*; import com.sun.j3d.loaders.objectfile.*; /** * An example for constructing an object (tetrahedron) with triangles * where normal vectors are interpolated. * * @author Frank Klawonn * Last change 05.07.2005 * @see GeomArrayExample */ public class Isocahedran extends JFrame { … | |
I have created a polygon (6 points). Lets call this one, outside polygon. inside the outside polygon I created smaller polygons. I want to flip all of it vertically. I know the points of the outside polygon and I have an ArrayList for the inner polygons. I was able to … | |
I have written a code in java for the following scenario. There is a class called Student and it has registration number and name as instance variables and student count as a class variable. Student class has two methods called display which is supposed to display the details of a … | |
I have a problem with serializing an Arraylist. This is my method to serialize Arraylist: public void serializeObj(){ ArrayList<Actor> novylist = new ArrayList<Actor>(); novylist.addAll(components); try { FileOutputStream fileOut = new FileOutputStream("zeditoru.ser"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(novylist); out.close(); fileOut.close(); }catch(IOException i) { i.printStackTrace(); } } components is Arraylist with theese … | |
how can i make a servlet to validate a form with two file upload one image and other a pdf file. along with the other string parameters like name age gender etc., i need to validate the pdf and image files in servlet and save it in folder of my … | |
| |
Often we're faced with the need to represent primitive data types as readable/writable bytes that can be sent through a data stream. In Java, there are classes such as DataOutputStream/DataInputStream that can do the work for us, but often a programmer wants to manage the conversions himself (or herself, to … | |
Here's my assignment question: > **Develop a Payroll class that consists of two user-defined methods, namely calculateNetPay() and printOutput() methods. The calculateNetPay() method is used to calculate the employee's net pay, as the formula follows: > > Net pay = gross pay - state tax and federal tax > > … |
The End.