- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 4
- Posts with Upvotes
- 3
- Upvoting Members
- 4
- Downvotes Received
- 3
- Posts with Downvotes
- 3
- Downvoting Members
- 2
58 Posted Topics
Re: I think it is ur project... u should think abt idea.. and then u should ask abt help in that direction.. if someone will be giving u any idea it means that will be available somewhere on net... otherwise one will patent it :P | |
Re: there is an obvious problem in your code.... u are storing user input in a string ... so it will always take last input. you should store input in a String array of size 2. `String [] testscore = new String[2];` and then 2nd for loop will be like this.. … | |
Re: ur code will not compile .... remove last '+' from your last line ie remove below line --------------------------------------- output="s1 = " +s1+ "\ns2 = " +s2+ "\ns3" +s3+; ------------------------------------------- with output="s1 = " +s1+ "\ns2 = " +s2+ "\ns3" +s3; | |
Re: Comparator interface: this is used to sort objects.. let say you are creating a arraylist and you are adding String or Integer in that arraylist, and after that if you are doinf Collections.sort(list); then it will sort this list in natural order. but assume if you are adding some Employee … | |
Re: check what have you done in ur product class constructor. [CODE] public Product (int id, String title, double cost, int total) { id = idNum; name = title; price = cost; quantity = total; }[/CODE] while it shoud be [CODE] public Product (int id, String title, double cost, int total) … | |
Re: read scjp, specially collection and threading. not only about functionality but implementation (source code) also [QUOTE=mckrm;1192965]i am new to Java and programming i just joined faculty of computer science and i am doing good but i think that all what i had until now isn't enough for my curiosity what … | |
Re: can u explain me wat u r trying to do .. [QUOTE=pirateninja1111;1192994]ok so what i am trying to do is create a random int and save it into an arraylist and sum up the contents of the array list. then ask the user if they would like to roll again. … | |
Re: [CODE] import javax.swing.*; public class RRunner { public static void main(String[] args){ int i; // counter int num; // number to be input int pw=0; // power of sum num = Integer.parseInt(JOptionPane.showInputDialog("Enter a number: ")); for( i=1; i<=num; i++ ){ pw += Math.pow(i, i); } System.out.println("The answer is "+ pw); … | |
Re: you can use singleton design pattern [QUOTE=ceyesuma;1192392]I was trying to figure out how to access variable values out of a class. if class x.java hold all the values can class y.java use getClass(??); to get values without making a new class instance(which will erase everything?). then class z.java access it … | |
Re: when you don't define any constructor in ur class then jvm will create a default constructor(with no parameter), but when u are creating any other constructor then default constructor will not be available. so either u create one default constructor as [CODE]public Car(){}[/CODE] or pass parameters in ur existing constructor … | |
Re: are you running this on command line... if yes, then tell me what all you are writing thr | |
Re: static methods should be called like this... ClassName.MethodName(params); while your approach is trying to call the constructor. it will be .... className.ItemFound(pistol, "No other items found in Bedroom", "You found Pistol", txt); [QUOTE=FancyShoes;1191084]Hi I am trying to return a boolean value into another method, but it's not working. [CODE] public … | |
Re: can u elaborate it.. or add rest of the code so that we can compile it and test | |
Re: [QUOTE=BestJewSinceJC;1191119]Use code tags and give better information. What do you mean you "hope that's it"? It is relatively easy to pinpoint a problem to a section of code. Did the code before that point execute properly? Did the code after it ever execute at all?[/QUOTE] yeah correct... code will never … | |
Re: [QUOTE=charlieruns;1190848]So im going to have to have [code]implements Comaparable[/code] and then make a compareTo method or something like the Photo Class?[/QUOTE] yeah implement Comparable interface in ur Photo class and override ur compareTo method.. try to understand this.. [URL="http://www.javapractices.com/topic/TopicAction.do?Id=10"]http://www.javapractices.com/topic/TopicAction.do?Id=10[/URL] | |
Re: it is perfectly fine.. only thing is naming convention is not correct. setname should be changed to setName, setcost should be changed to setCost .............. otherwise everything else is fine | |
Re: [QUOTE=lion hunta;1189313]I need help fixing my telephone keypad application, it will compile but when I run it, it doesnt work someone please help[/QUOTE] it throws ArrayIndexOutofBound exception.. reason is that your Button array size is 12 -------------------------------- keys = new Button[12]; ---------------------------------- while you are trying to add element at … | |
Re: we don't call constructor like this,,, change ur main method.. [CODE] public static void main(String[] args){ Image image = new Image(3,4); Color color = image.getPixel(0,0); System.out.println("This is the color at 0,0 "+ color); } [/CODE] | |
Re: [CODE] import java.io.*; import java.util.*; public class SortStringsFromFile { public static void main(String[] args)throws IOException { // O = Orginal // S = Sorted String[] Ostring = new String[100]; String[] Sstring = new String[100]; int sizeN = ReadFile(Ostring, Sstring); sizeN = sizeN>=100 ? 100:sizeN; String[] Ostring1 = new String[sizeN]; String[] … | |
Re: you can create an Arraylist, and whenver isDirectory is true. add it in ur arraylist.. pass that list as a parameter in other call. | |
Re: Arrays.binarySearch(array,char) gives the index try this [CODE]if (Character.isUpperCase(num)){ System.out.println(num+" is Upper case"); System.out.println("Index is = "+(Arrays.binarySearch(upper, num)+1)); } else{ System.out.println(num+" is Lower case"); System.out.println("Index is = "+(Arrays.binarySearch(lower, num)+1)); }[/CODE] | |
Re: [CODE]public boolean isAllValidDigits() { boolean returnFlag = true; for(int i = 0; i < authorId.length; i++){ if((authorId[i] < 0)||(authorId[i] > 9)){ // as soon as any number not in the range change the flag and break; returnFlag=false; break; } } /// no need to chk if flag is false if(returnFlag) … | |
Re: [QUOTE=sinister747;1187337]Thanks for the help, but if you don't mind how exactly can i do a greater or less with Strings? i would presume alphabetically but is that really veasible?[/QUOTE] inside compareTO you should use compareTo again which will return 1/0/-1, you shouldnt do < but compareTo ... for example. [CODE]public … | |
Re: [QUOTE=neti1987;1187613]Hi! I try to create HashSet of the next object: [CODE] import java.nio.file.Path; public class WatchedPath { public Path dir; public boolean recursive; public Filter filter; // Ctor with only Path - for comparing between the object (comparing is only by the path!) public WatchedPath(Path dir) { this.dir = dir; … | |
Re: I think txtOnline should be null..... print txtOnline just inside the showSchools method | |
Re: [QUOTE=Colin454;1187253]Hello, apon summing the rows of a two-dimensional array how can you put the results into a new 2D array so that the results can be sorted from largest to smallest or vice versa? we started with a 7 column 8 row array and now want a two column 8 … | |
Re: [QUOTE=moutanna;1182516]the error is here: this.aDiameter[i] = aDiameter + 2; it is not permited to assign an array to an integer value.[/QUOTE] No man this will not be a problem... you are adding integer in ur array , which is perfectly correct. Original post doesnt contain full code and it is … | |
Re: [QUOTE=yacin87;1185468]hello to everybody I have a linked list that contains objects each object contains two String field I want to know how to check if the object that i want insert is already exists in the linked list thank you[/QUOTE] List<String[]> list = new LinkedList<String[]>(); you should check int n … | |
Re: it will throw an exception whereever you dont have any extension for a file... so when you are checking indexOf("."), thr you put and if/else clause if(index>0) { }else{ } | |
Re: change below line ---------------------------------------------- System.out.printf( "the answer is %d ", z ); ----------------------------------------------- to ------------------------------------------- System.out.printf( "the answer is %f ", z ); -------------------------------------------- | |
Re: lot of mistakes are thr... when you are trying to remove it 1. on the very first iteration your this line is throwing nullpointer ----------------------- if( top.getKey() <= heapArray[smallerChild].getKey() ) break; ------------------------------- because top == null now when I handle null pointer here and change code to ----------------------------------------- if(top!=null) if( … | |
Re: if you are using compareTo for two objects then that object should implement comparable interface. and compareTo will be used to compare two objects while you are using only one. it will be object1.compareTo(object2) For example. String implements comparable interface. String test = "hi"; String test1 = "HI"; System.out.println(test.compareTo(test1)); cheers … | |
Re: public Staff(String name,String address,String phone,String email, String title){ super(name,address,phone,email,title); this.title=title; } chk above code... constructor doesnt exists in Employee class. you should have 6 arguments while you are passing 5 | |
Re: where is the confusion, 2nd and 3rd constructors will work like 1st one only. Whatever arguments you are passing in constructors that you can set to length/width/height. for ex for the second constructor: public Box(int l, int w) { length = l; width =w; height=0; } and setters and getters … | |
Re: method signature is fine ... but method is wrong.. you are calculation cylinder volume instead of area. cylinder area will be 2*pi*r*r +2*pi*r*h | |
Re: jokeList.get is giving this problem... you arraylist is not populated and when you are trying to get it from selected index it is throwing this exception | |
Re: ahh ... small mistake ............. you can compare strings with "==", you should use .equals replace line number 51 (if (choice == "1")) with if (choice.equals("1")) I am assuming that you know the difference between "==" and .equals. if no then below is the diff: == compares the reference while … | |
Re: follow these steps: 1. let say you need to findout all the primes till number n 2. create a outer for loop which will iterate from 1 to n (let say int i) 3. create a inner for loop(int j) and chk i%j 4. for prime numbers i%j will be … | |
| |
Re: 1. Create a Arraylist for returning the result(out side the while loop) 2. Create comma separated string of all the columns outside the while loop; 3. Inside while loop split this string with "," and you will get string array. 4. iterate this string array and get value (rs.getString) for … | |
Re: Code is perfectly fine. int...ints is a varargs parameter and it is a java5 addon. with varargs you can send multiple parameters and it will always be the last parameter in method signature. [url]http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html[/url] | |
Re: can u write the complete code so that it will be easy to find out what exactly you are trying to do | |
Re: Try to rewrite it again and then come with confusion. I tried to copy the same code and got so many errors and started fixing it but after sometime I found that it doesnt contain few but tons of errors. code as lot of errors, braces are not closed properly, … | |
Re: is it a code... Dont mind but first try to read the basics then start asking the questions. Read about object, method and variables | |
Re: Assign smallestindex to j and print smallestindex instead of currentValue is this code written by you, reason of this question is that if someone is able to write this much of code then how come he is missing one simple line... |
The End.