32,204 Topics
| |
public class QS { public static <T extends Comparable<? super T>> T[] quickSort(T[]array) { return doSort(array, 0, array.length - 1); } //some other methods................. public static void main(String [] args){ QS qs = new QS(); int [] nums = {4,7,23,1,2,45,23,11}; qs.quickSort(nums);//gives error } } I am getting an error in … | |
Im trying to get the output to read on one line such as this: Reference String 1 2 3 where 1,2,3 is the number the user enters. Instead the output is as such: 1 2 3 Reference String. How can I improve this to read correctly? import java.util.Scanner; public class … | |
The code below works: public class concat { public static void main(String[] args){ String[] filters = {"A","B","C","A","K","C"}; String[] values = {"1","2","3","4","5","6"}; String a = ""; for(int i=0;i<filters.length;i++){ String temp = filters[i]; for(int j=0;j<filters.length;j++){ if(filters[j].equalsIgnoreCase(temp)){ a += values[j] + " "; values[j]=""; } } if(a.trim().length()!=0){ System.out.println(temp + " [" + a … | |
Having an error code and my brain is fried. Can someone please help Here is the part of the code that the exception points to. | |
import javax.swing.* ; import java.awt.event.*; import java.awt.*; import java.io.*; import java.util.Calendar; import java.util.*; import java.text.*; /* <applet code="gui.class" width=250 height=100> </applet> */ class gui extends JApplet implements ActionListener { JTextField t1,t2,t3,t4,t5; JLabel l1,l2,l3,l4,l5,l6; JButton b1,b2; Calendar c1,c2,c3; JPanel p,p1,p2; Date sd,sd1; SimpleDateFormat sdf; public void init() { SimpleDateFormat sdf = … | |
/*I am trying to generate 6 random unique (1-49) no.s and understand that my validation is incorrect.Help Please?*/ [code] import java.util.*; import javax.swing.JOptionPane; public class ranUnique { public static void main(String[] args) { String output=""; int[] arrayRan=new int[6];int ran2; for(int ran=0;ran<arrayRan.length;ran++){ arrayRan[ran]=(int)(Math.random()*50 //validate for(ran2=0;ran2<=ran;ran2++){ if ((arrayRan[ran]==arrayRan[ran2]) || (arrayRan[ran]==0)) { arrayRan[ran]=(int)(Math.random()... … | |
hi guys, am stil new to java their was a snippest code about getting screen size i've being seeing onine calling window.getSize() in what package is the object located. // Get the size of the screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); // Determine the new location of the window int w … | |
Derive an algorithm which updates the ith elements from the top of the stack, upgrade this algorithm to calculate the maximum value among the contents of the task. Hence write a java program to implement this task | |
Hi everyone,can anyone explain to me how to develop the Sokoban game in Java?Like a step by Step,am a newbie | |
HI, could someone explain me this line of code: public void createTextFile(Layer layer, String prcString, String arString) { File fileStatPercent = new File(fileName+layer.getName() + "Test.txt"); try { BufferedWriter out = new BufferedWriter(new FileWriter(fileName + layer.getName() + "Test.txt")); out.write("something"); out.newLine(); out.write(prctString); out.newLine(); out.write("something"); out.newLine(); out.write(arString); out.write("\n"); out.close(); Thank you, i don't … | |
Hi! I'm a 2nd Year IT Student and right now I have a problem in creating an Address Book Program using Java Codes.. It has never been discussed to us in class so i really don't know how to do it but look for it online.. I have used Mr./Ms. … | |
Hi all, I have a program that I have to write with an output that looks like this: ---------------------------------------------------------- Wages for 3 employees For 10 hours worked, the wages are 120 dollars For 20 hours worked, the wages are 240 dollars For 30 hours worked, the wages are 360 dollars … | |
i need help wit the source code for sokobane game ,starting from the main program | |
I need to design an application that reads a string from the user, then determines and prints how many of each lowercase vowel appear in the entire string. Separate counter for each vowel. I also need to count and print the number of consonants, spaces, and punctuation marks. The problem … | |
Need help writing code for generating random triangles. You will have the following functions (no violation of these interfaces) and you may have others, as needed: − public static void GenerateRandomTriangles(int numTriangles) to create a file RandomTriangles.dat having the following format (including some comments like the ones shown below) with … | |
consider public class awah{ private int x=0; private int y; private int w; public awah(int width){ w=width; } public void sety(){ y=(Int)(Math.random()*4);}//meth1 public int gety(){ return y; } public void setx (){ x+=this.gety(); } public int getx(){ return x; } public void showUpdate(){ System.out.println(x); } }//end of awah public static … | |
I need to design and implement an application that produces a multiplication table, showing the results of import java.util.*; import java.text.*; public class MultTab7 { //---------------------------------------------------------------------------------------------- // Creates a multiplication table. //---------------------------------------------------------------------------------------------- public static void main (String[] args) { int MAX = 12; for (int r=1; r<=MAX; r++) { for … | |
Hello guys. I need to write a client-server app that provides a simple Lotto server and client to generate a user-defined sequence of random numbers in the range 1 - 42. The system operates as follows: 1) Client sends a string message to the server indicating the operation to be … | |
I am currently trying to establish SSL connectivity using eToken via PKCS11. The PKCS11 provider is setup and I can read the 3 stored certificates as a key Store Object. But I am getting the following exception while trying to establish SSL connectivity. I am using JDK 6.0(java version "1.6.0_31-rev). … | |
i made this code to loop number for(int i=0;i<4;i++){ double temp[i]=Math.random() * i*10; system.out.println("Result" +i+ "=>" +temp); } output : Result 0 => 14.3 Result 1 => 11.4 Result 2 => 10.8 Result 3 => 12.4 now, i want to sort by ascending this output based on value with keep … | |
I need to get specific objects deleted from a LinkList, but the deleted items come from a stack of sorted State objects, but the Statename is the only value. I am trying to compare the statenames when using deleteKey, but for some reason it is not working at all. I … | |
Hi all, I need help in writing a method that calculates & returns a person's age (in years)given instance variables day, month & year all of type integer(int). | |
Hi, I have a desktop app in Swing. Now i want a javascript function like mailto when I click a JButton. Please help or provide any suggestion on my approach. Thanks in Advance. :) | |
I am able to insert the document with attachments in it as blob into Oracle DB. I am able to download the same document with the same attachments. But When I open it(blob) with Document Builder and write some lines of text in it and convert back to Blob and … | |
I am trying to write a Java program to download youtube videos. When I search in internet I found that most of the codes use to get the index of "url_encoded_fmt_stream_map=" from the YouTube page source. I think this is to extract the exact video format link. But I am … | |
## Sub-Heading Here ## hello guys, am new here and am looking forwad to getting a lot of help and helping others as well. I have an assignment that requires a program that outputs the numbers 1,2,4,8,16,32,64,128 using a loop. | |
i get this 'else' without 'if' error on this case: case 2: for(int i=0;i<currentRegisterdItems;i++){ System.out.println("#"+i+" - "+itemArray[i] + "\t\t\t" + priceArray[i]); System.out.println("Select products and add to cart - Simple Shop Software"); System.out.println("Enter the product id: "); int searchIdProduct = Integer.parseInt(a.readLine()); if(itemArray[searchIdProduct] != null){ System.out.println("Add "+itemArray[searchIdProduct]+" to your cart?"); System.out.println("Confirm: Y … | |
public class IC1 { private int x = 3; static int y=4; class Inner { public void inmet() { System.out.println(x + " " + y);} } public void do() { Inner i = new Inner(); i.inmet(); } public static void main(String r[]) { IC1 ic = new IC1(); ic.do(); } … | |
Hi All, I am a newbie of 8 weeks enjoying the challange of trying to understand java. I was assigned to create a rather challenging program in which the user is prompted to input a number from 1 to 10,000,000 then the number outputs in english words. For example- please … | |
Hello Friends, I want to set the length of the textfield in java... Please check my below code....it works finely if I press the keys one by one slowly... But suppose if I press any key for a longer time the actual length exceeds and so the validation is not … |
The End.