Posts
 
Reputation
Joined
Last Seen
Ranked #1K
Strength to Increase Rep
+6
Strength to Decrease Rep
-1
85% Quality Score
Upvotes Received
33
Posts with Upvotes
33
Upvoting Members
17
Downvotes Received
5
Posts with Downvotes
5
Downvoting Members
4
13 Commented Posts
0 Endorsements
Ranked #280
~164.51K People Reached
Member Avatar for student.09

[CODE]public class MyPoint { private int x,y; public MyPoint(){ x=0; y=0; } public MyPoint(int x, int y){ this.x=x; this.y=y; } /* now Two get methods for data fields x and y, respectively. */ ..... }[/CODE]

Member Avatar for sahil_26
0
7K
Member Avatar for prem2

You may declare a method (in java we call function as method) as abstract which means no definition is given, e.g. [CODE]void show();[/CODE] You may declare a method with empty body, which isn't an abstract method anymore. [CODE]void show(){};[/CODE] but do nothing when calling it. Or you may define a …

Member Avatar for JamesCherrill
0
4K
Member Avatar for Techboy52

The JOptionPane's showMessageDialog is indeed shown, but it is covered by the DOS window. After you move the DOS window away you will be able to see the JOpationPane's showMessageDialog. This is my observation.

Member Avatar for stultuske
0
4K
Member Avatar for ezkonekgal

Your code shown above is correct. I have tested with a known file. The result is correct. AS long as the browsing files is concerned, as jon.kiparsky indicated, it is already available in Swing. For example, the class FileDialog is a candidate for this purpose. Since its constructor requests a …

Member Avatar for emoon11
0
2K
Member Avatar for jtresue

Your forgot to add the component userMessageLabel into container: [CODE]add(userMessageLabel); // this line of code is missing[/CODE] Please use CODE tag to post your code so that one may refer your certain code to a specific line number

Member Avatar for JamesCherrill
0
3K
Member Avatar for loozax

StringBuffer has an instance method: reverse() to do the reversing job. [CODE]import java.io.*; import javax.swing.JOptionPane; public class Palindrome{ static boolean palindromeCouplet (String s) { StringBuffer s1 = new StringBuffer(s); return ((s.compareTo(new String(s1.reverse()))==0) ? true :false) ; } public static void main(String[] args) { while(true){ String str=JOptionPane.showInputDialog( null, "Type in a …

Member Avatar for JamesCherrill
0
699
Member Avatar for xterradaniel

Following javaAddict's code, I have replaced the BufferedWriter and FileWriter with BufferedReader and FileReader. In order to get each integer value back, the method of class String split is given the delimiter of a space " ". Please read the method of String split(...) in API. Therefore, for reading the …

Member Avatar for nate.nelson.566
0
3K
Member Avatar for bymak87

Please have a look at the thread: [URL="http://www.daniweb.com/forums/thread299093.html"]array sort of 10 integers in ascending and descending order Bubble sort http://www.daniweb.com/forums/thread299093.html[/URL]

Member Avatar for nate.nelson.566
0
1K
Member Avatar for amit.hak50
Member Avatar for rajesh_tawari

Animation in Java JDBC application Statistics on English words obtained from a text file Some demonstration on data structure

Member Avatar for stultuske
0
362
Member Avatar for toferdagofer

In constructor you redefine the label2,label4,label6, and label8 as local variable of the type JTextField, which is wrong. You have already declared them as attributes. You should thus replace the 8 lines of code in the constructor by the following code: [CODE]JLabel label1 = new JLabel("Enter the price of one …

Member Avatar for DavidKroukamp
0
1K
Member Avatar for Litcandle

[CODE]import java.io.*; import javax.swing.JOptionPane; public class PalindromeCouplet{ static boolean palindromeCouplet (String s) { StringBuffer s1 = new StringBuffer(s); return ((s.compareTo(new String(s1.reverse()))==0) ? true :false) ; } public static void main(String[] args) { while(true){ String str=JOptionPane.showInputDialog( null, "Type in a string!\nPress Cancel to terminate the program", "Palindrome or Not?", JOptionPane.QUESTION_MESSAGE); if …

Member Avatar for stultuske
0
392
Member Avatar for VinC

Thank you, VinC, for sharing the "Covariant". line 22 shows that g is a variable of type Grain. line 25 shows that a variable of type Grain is capable to receive a value of type Wheat. Why? Because Grain is super class of class Wheat. Wheat is a kind of …

Member Avatar for DavidKroukamp
0
156
Member Avatar for perlsu
Member Avatar for mubin_89
1
4K
Member Avatar for AhmedGhazey

It happends with Chinese characters as well. I think this is probably due to the computer system (windows' config) where your output is printed.

Member Avatar for ahmaadaadel
0
3K
Member Avatar for webmasts

A further development of extemer's program leads to the following table showing the furture values of one thousand dolloars investment calculated based on compound interest: a(t) = (1 + i)^t where i is rate while t the number of years [CODE]import java.text.DecimalFormat; import javax.swing.*; import javax.swing.JTextArea.*; class TextAreaDemoB { public …

Member Avatar for Donkerster
-1
1K
Member Avatar for lynnajoe
Member Avatar for desert564

The main method should be written as follows: [CODE]public static void main(String args[])throws IOException { sp obj=new sp(); obj.takenum();obj.showresult(); }[/CODE]

Member Avatar for desert564
0
89
Member Avatar for sach_ak47

If you have already had JDK 1.6 in your machine then download [URL="http://www.oracle.com/technetwork/java/javame/downloads/sdk30-jsp-139759.html"]Java ME SDK 3.0 http://www.oracle.com/technetwork/java/javame/downloads/sdk30-jsp-139759.html[/URL] do some programing in J2ME Then under your working folder : [B]projectName/dist/[/B] you may find the corresponding file ***.jar ready for mobile phone .

Member Avatar for Hakoo
1
927
Member Avatar for jwmollman

(1) The code in the line 12 is not correct. The code in line 12 could be: intTotal = intTotal + intCounter; or intTotal += intCounter; (2) The code in line 13 should be moved/inserted into the place between the line 14 and 15. (3) The initial value for the …

Member Avatar for kikovi
0
181
Member Avatar for flyingcurry

(1) flyingcurry ,if you have to sort the whole array the second argument “length” is redundant. In fact, the length is the array.length。 (2) The line 13 could be replaced with [CODE]for (j=0; j<length-1-i; j++) //to avoid the unnecessary comparisons made of the stable region.[/CODE] See [URL="http://www.daniweb.com/forums/thread299093.html"]the post on bubble …

Member Avatar for apines
0
176
Member Avatar for spades0001

One should write the following line of code to update the control variable ctr (the ODD numbers less than 10): [CODE]for (;ctr<=10; ctr+=2, ctr2++) {[/CODE]

Member Avatar for tong1
0
128
Member Avatar for ceyesuma

Just for your [URL="http://docs.python.org/tutorial/datastructures.html"]reference.[/URL] In Pyphon the list data type has a method: pop(). list.pop([i]) removes the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list. (The square brackets around the i in …

Member Avatar for ceyesuma
0
288
Member Avatar for frankel81

The difference between two adjacent numbers in the series of numbers increases one each time. Therefore, one has to update the difference by one increment each time: [CODE]difference++[/CODE] Hence one may calculate the next number by the following code: [CODE]num +=difference++;[/CODE] Therefore the for each loop could be written as …

Member Avatar for Eric Cute
0
149
Member Avatar for ssubnel

(1) You may define the method as the main(). Hence replace the line 8 with [CODE]public static void main(String args[] ){[/CODE] (2) You forgot to create the instance of Scanner: input. Hence insert line 8 the following code: [CODE]Scanner input=new Scanner(System.in);[/CODE]

Member Avatar for ssubnel
0
94
Member Avatar for mbouster

The UML for the class MyPoint could be written as follows: -x : double -y : double +MyPoint() +MyPoint(x:double,y:double) +getX() : double +getY() : double +setX(x:double):void +setY(y:double):void +distance(AnotherPoint:MyPoint):double +distance(p1:MyPoint,p2:MyPoint):double

Member Avatar for tong1
0
604
Member Avatar for Lxyslckr

Note that the instructor asks to verify the value provided for "year" is at least 1908 and at most 2012, hence the code should be: [CODE]if (y >= 1980 && y<= 2012) year=y; else year=2010;[/CODE] The following code by using ternary operator is also valid: [CODE]year = ( y>=1980 && …

Member Avatar for Lxyslckr
0
102
Member Avatar for riahc3

The class Math in the package java.lang has a static method random() which returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. I use this method to generate random number. For example, to generate a integer varying from 0 to 255 …

Member Avatar for tong1
0
155
Member Avatar for vishalonne

In the definition of class EnemyShip, you may add a static int attribute numEnemieShip from which you may know the number of enemy ships created from time to time. Hence, the constructor is defined as follows: [CODE]public EnemyShip(int x, int direction){ this.x = x; this.direction = direction; numEnemieShip++; }[/CODE]

Member Avatar for JamesCherrill
0
171
Member Avatar for muraj

In this case you should cast the result of the evaluation of "xCenter + 200 * Math.cos(2 * Math.PI * 3 / 7)" or "yCenter + 200 * Math.sin(2 * Math.PI * 3 / 7)": [CODE]g.drawLine ((int)(xCenter + 200 * Math.cos(2 * Math.PI * 3 / 7)),(int)(yCenter + 200 * …

Member Avatar for muraj
0
106