211 Posted Topics

Member Avatar for tinamary

[B]Normal class:[/B] Normal class has definition of methods and variables and their declaration as well. [B]Abstract class: [/B] Abstract class has methods and variables with definition and declaration as well like the normal classes. Hoewever it must have at least one method with no implementation, which hence is called abstract …

Member Avatar for jon.kiparsky
0
155
Member Avatar for Yaserk88

Some error in your code: line 5 should be [B]S[/B]ystem.out.println(...) line 4 should be float number = r.[B]nextFloat[/B](); If the range of current random is [0,1] then [CODE][B]float[/B] number = -1 + 2*r.nextFloat();[/CODE] the random number varies in the range of [-1,1]

Member Avatar for tong1
0
98
Member Avatar for NewOrder

Calling [B]String toString() method[/B] shows that the JVM would dynamically identify the objects of cat, Dog, Duck, and Cow since the array stores their references respectively. Therefore neither [B]casting[/B] nor the [B]instanceof operator[/B] is needed. An Object array may store a reference of any kind of type. [CODE]public class Part5{ …

Member Avatar for NewOrder
0
118
Member Avatar for iSax

Note: order of execution in loop body has been altered. Use psuedo code to express the algorithm: • set sum to 0 • set number_counter to 1 • while number counter <= 100 do the following loop: [I] sum = sum + number_counter add 2 to the number_counter[/I] • Print …

Member Avatar for JamesCherrill
0
99
Member Avatar for nirvan v. jain

Some google search result: strictfp is a keyword in the Java programming language that restricts floating-point calculations to ensure portability. It was introduced into Java with the Java virtual machine (JVM) version 1.2. [URL="http://en.wikipedia.org/wiki/Strictfp"]http://en.wikipedia.org/wiki/Strictfp[/URL] [URL="http://www.java-samples.com/showtutorial.php?tutorialid=333"]Frankly, most programmers never need to use strictfp, because it affects only a very small class …

Member Avatar for tong1
0
170
Member Avatar for fringe

Should we modify the formula ? selection menu : 1.Area of a Circle ----(3.14 * (r*r)) 2.Area of a Trapezoid ---- (height * (base1+base2) / 2) 3.Volume of a Sphere ---- ( 3.14 *(radius*radius*radius)/.75) 4.Volume of a Cylinder ---- (3.14 * (radius * radius) * height)

Member Avatar for tong1
0
123
Member Avatar for churva_churva

[QUOTE]how to do the displaying of objects in array program using an interactive console/gui [/QUOTE] If the Object array is ObjectArray where the elements are of various types the following traversal loop may be useful. [CODE]for (Object o: ObjectArray) System.ou.ptinrln(o);[/CODE] If you are going to add/delete an element into/from an …

Member Avatar for tong1
0
118
Member Avatar for Waseem Siddiqui

I have no solution for this thread, but I have a comment on above coding. class b extends a. The following line of code leads to a compiling error. [CODE]b obj = new a();// The instance of a super class cann't always be the one of its sub class.[/CODE] The …

Member Avatar for JamesCherrill
0
222
Member Avatar for churva_churva

Is the array your teacher asks you to create a type of Object, or a concrete type defined by you, or a primitive data type? If an object is added, is it added before the first element or after the last element, or somewhere expected? Please provide certain specification.

Member Avatar for churva_churva
-1
286
Member Avatar for jemz

Use StringTokenizer in java.util.* to get each word as a token. The delimiters include space character, and other interpunction。

Member Avatar for jon.kiparsky
0
126
Member Avatar for Katana24

As JavaAddict points out, it is the checking issue that makes Katana24's method does not work perfectly. Therefore, some code has to be modified as: [CODE] for( int i = 0; i < myArray.length; i++ ) { try { int currentValue = Integer.parseInt( sT.nextToken().trim() ); myArray[i] = currentValue; }catch(NumberFormatException e){ …

Member Avatar for tong1
0
1K
Member Avatar for ubi_ct83
Member Avatar for Victor C.
Member Avatar for Victor C.
0
75
Member Avatar for Vivek Venkatesh

Please have a look at [URL="http://www.daniweb.com/forums/thread300029.html"]the post[/URL] for your reference. In this project a statistics has been made on the words in a text file.

Member Avatar for VernonDozier
0
1K
Member Avatar for rowley4

One error: In line 7 you define name as String instead of String array. Suggestion: (1) Should we just use the argument of the main method so that the body of the main method will be: [CODE] sortStringBubble (args); for ( String s: args ) System.out.print( s + " " …

Member Avatar for tong1
0
301
Member Avatar for Megha SR

Megha SR Even you have corrected all the errors accordingly you are still unable to run this program. If you run it, the following error will be printed: Exception in thread "main" java.lang.NoSuchMethodError: main You should define a proper main method which requests only one argument: a String array: String …

Member Avatar for NormR1
0
76
Member Avatar for sumeetdesaeee

See [URL="http://www.javaworld.com/javaworld/javaqa/1999-08/01-qa-static2.html?page=1"]Static class declarations by InfoWord-JavaWord[/URL] “You declare a top-level class at the top level as a member of a package. Each top-level class corresponds to its own java file sporting the same name as the class name. A top-level class is by definition already top-level, so there is no …

Member Avatar for JamesCherrill
0
78
Member Avatar for TahoeSands

An array is a container object that holds a fixed number of values of [URL="http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html"]a single type.[/URL]” (true for some cases only) [URL="http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html"]http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html[/URL] In broad sense, I would say: “An array is a container object that holds a fixed number of values of either a single type or different types/multi-types.” …

Member Avatar for JamesCherrill
0
957
Member Avatar for gretty

One may replace peter_budo's code 38-44 with the following c-style code: [CODE] System.out.printf("max=%2d", max); for (String s: adjective) for(String n: noun) System.out.printf("\n%s as %s",s , n);[/CODE] I also tried to use this style in initiating the string array noun, e.g. replace : [CODE]for (int i=0; i<cNoun; i++) noun[i] = scan.next(); …

Member Avatar for tong1
0
214
Member Avatar for developer@india

One byte of menory is requested for storage of a value/variable of boolean data type

Member Avatar for ~s.o.s~
0
223
Member Avatar for ankilosado

You may replace the code in line 24 where the error occurs by the following two lines of code: [CODE] int va = this.statVect[i].getValor(); va += otroVect[i].getValor(); this.statVect[i].set(va);[/CODE] Can you answer me Why we should modify in this way?

Member Avatar for ankilosado
0
180
Member Avatar for glenak

The reason is: the loop body still needs i. the (i=cis.read(cipherTextBytes)) is consider as the returning value. If the value returned is not -1 the loop continues.

Member Avatar for JamesCherrill
0
119
Member Avatar for hazeeel

Over one month ago there was a thread discussing the similar project which might help you: How to extract columns of coordinate values from text file (in java) ? [URL="http://www.daniweb.com/forums/thread294844-1.html"]http://www.daniweb.com/forums/thread294844-1.html [/URL]

Member Avatar for NormR1
0
198
Member Avatar for herberwz

(1) In void actionPerformed(ActionEvent e)method body there are missing code blocks for two cases: if (e.getSource() == displayBtn){...} and if (e.getSource() == resetBtn){...} (2) in void actionPerformed(ActionEvent e)method body one curly bracket '}' is missing in line 178 That's why, I guess, the buttons do not work properly.

Member Avatar for NormR1
0
117
Member Avatar for anz2050

I do not understand your question. Anyway, I am nocited that to capture the output in DOS window one may use pipe: java ABC > data.dat so that the output by intepreting ABC will be captured/stored in the file data.dat

Member Avatar for anz2050
0
248
Member Avatar for hazeeel
Member Avatar for javaAddict
0
52
Member Avatar for capsitan

boolean variable "stop" is a sentinel flag. If "stop" is true the "while loop" must terminate immediately. So you should check the empName to see if it is "stop" or not. Therefore, the lines of code starting for checking the name would be: [CODE]if( empName.equalsIgnoreCase("stop")) stop=true; // stop becomes true …

Member Avatar for tong1
0
416
Member Avatar for jemz

skyzer, Is the n an instance of Node or that of String? I think some things in jemz declare of the method "remove" should be altered as : public boolean remove(String n) {...} provided the definition of the class Node is wirtten as : [CODE]class Node { String item; Node …

Member Avatar for jemz
0
289
Member Avatar for capsitan

This thread seems to come from the same thread in [URL="http://www.daniweb.com/forums/thread304961.html"]http://www.daniweb.com/forums/thread304961.html[/URL]

Member Avatar for tong1
0
161
Member Avatar for jk_bscomp

In Unix/Linux/DOS windows the commands for compiling and runing java program are the same provided the environmental variable is set up properly. javac Hello.java java Hello If you develop an applet application, you may use appletviewer Hello.html to open the html file Hello.html to run the applet.

Member Avatar for tong1
0
368
Member Avatar for prem2

static methods/variables are associated with class-wide situation which has one copy only while non-static, i.e. member methods/variables belong to each instance. Each instance/object has its own copy of its methods/variable. You may use super's class name to replace the handle "super": [CODE]one.show(); [/CODE] to meet your purpose. In other word, …

Member Avatar for tong1
0
101
Member Avatar for keanoppy

According to NormR1's suggestion, (1) Add one space character as an extra delimiter into the sDelim string in line 8: String sDelim = ".? !"; (2)Insert the following line of code after line 14 if (s1.compareTo("do")!=0) so that the "do" will not be printed on DOS

Member Avatar for keanoppy
0
259
Member Avatar for tedtdu

May I suggest you write a program to open and read a file, and the file name is the first String argument ( args[0]) for the main method : public static void main(String args[]) {...} so that each time your command should simply be : java XML input1.txt

Member Avatar for tedtdu
0
133
Member Avatar for Garee

The for loop body shows that after assignments are made to every elements of the array diveScore the guard starts to check the "input variable element". (It's too late). Actually no assignment has been made to the variable element. If only the values varying from 0 to 10 are acceptable …

Member Avatar for jon.kiparsky
0
114
Member Avatar for toferdagofer

The data type of choice is int. So you should define each case by a constant of type int. Therefore the case bady should be: [CODE]case 1: howKilometers(meters); break; case 2 : showInches(meters); break; case 3 : showFeet(meters); break; case 4 : System.exit(0); default: JOptionPane.showMessageDialog(null, "Invalid number");[/CODE]

Member Avatar for toferdagofer
0
139
Member Avatar for dadam88
Member Avatar for toferdagofer

Should we first establish the input channel properly? (1) In line 20 the "input= " is missing. The corrected code would be: input = JOptionPane.showInputDialog("Enter the next number"); (2) lines 15, 16 are deleted. (3) before comming into the while loop the variable number should be initiated, e.g., as 0. …

Member Avatar for toferdagofer
0
202
Member Avatar for Xufyan

The method name should always be starting with lower case conventionally speaking. the code should be: [CODE]ch=value.charAt(i);[/CODE]

Member Avatar for Xufyan
0
260
Member Avatar for Melow

If you use the image file in your own computer to create a ImageIcon instance, e.g. img1, the code in the first post you made will work well. You may simply replace the URL in line 11: "http://calindragan.files.wordpress.com/2010/06/pictura_muzica.jpg" by "/home/noon/workspace/eclipse/Applets/src/images/ima1.jpg" Try it.

Member Avatar for tong1
0
164
Member Avatar for SC803

You may learn how to write Psuedo code from web sites, such as [URL="http://www.unf.edu/~broggio/cop2221/2221pseu.htm"]http://www.unf.edu/~broggio/cop2221/2221pseu.htm[/URL] Following the samples overthere we may write as follows: create an input channel ask client to type in score convert the input into int variable if .....

Member Avatar for tong1
0
104
Member Avatar for jiraiya

I added a main method so that the program runs. [CODE]public static void main(String args[]){ Display dis=new Display(); dis.setVisible(true); dis.setSize(500,150); dis.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); }[/CODE] I put an icon.png in the same folder. both the program and the button works. The problem is that the icon will be located before the text rather …

Member Avatar for tong1
0
212
Member Avatar for Sugarskull

The line 23 should be replaced by [CODE] if ((suit !='C') || (suit !='D') || (suit !='H') || (suit !='S')) [/CODE] If your intention is logical OR. Probably, your intention is logical AND as javaAddict indicated(?).

Member Avatar for Ezzaral
0
276
Member Avatar for Hawkpath

Due to Java security reason if a class extends Applet it cann't: save any records on a file open and read a file, and alter a file. However it may record scores in an array. As long as the program runs, one may access the data. If the program terminates …

Member Avatar for NormR1
0
449
Member Avatar for jemz

code line 17 is not correct: BufferedReader br = new BufferedReader(new BufferedWriter((System.in))); The argument should be a Writer object. I have modified the program by Java source code example for your reference. [url]http://www.javadb.com/write-to-file-using-bufferedwriter[/url] The data you typed in will be stored in myFile.txt In one line type in "end" only …

Member Avatar for tong1
0
116
Member Avatar for prem2

Default constructor is the constructor with no arguments requested. It is called implicitly when creating an instance. [CODE]import java.io.*; public class DefaultConstructor { public DefaultConstructor() { System.out.println("I am Default with no arguments."); } public static void main(String[] args) { DefaultConstructor d = new DefaultConstructor(); } }[/CODE] output: I am Default …

Member Avatar for tong1
0
10K
Member Avatar for jemz

[CODE]class Node { // The definition of the class Node String value; // data member Node next; // self referencing: referring to itself }[/CODE] Self-reference occurs in natural or formal languages when a sentence or formula refers to itself. [URL="http://en.wikipedia.org/wiki/Self-reference"]http://en.wikipedia.org/wiki/Self-reference[/URL]

Member Avatar for jemz
0
6K
Member Avatar for rogue005

Match in size (the same width and height) or Match in the ratio of width over height, or by other criteria?

Member Avatar for NormR1
0
75
Member Avatar for priyanca

[LIST=1] [*]Animation in Java [*]Data Structure in Java [*]JDBC [*]Natworking programing in Java [*]Statistics on words in text file by Java [/LIST]

Member Avatar for tong1
-1
343
Member Avatar for enazi

(1) May I ask: Why only press "return key" to do something? You may do something when receiving other input string. (2) One class may implement the interface KeyListener to listening to the keyboard. (3) I have written a simple program using KeyAdapter to monitor the keyboard for your reference. …

Member Avatar for enazi
0
2K
Member Avatar for nocookies92

You have incorrectly placed these lines of code outside of methods. This means that you are declaring attributes for your class. When you declare an array, you may initiate the String array with the corresponding values at the same time. However you wrote assignments' code during declaration, which is wrong. …

Member Avatar for nocookies92
0
124

The End.