35,618 Topics

Member Avatar for
Member Avatar for moaz.amin.37

i write a code of multithreading in which arise an race condition code is below class Race1{ public void show(String s){ try{ System.out.print("["+s); Thread.sleep(1000); }catch(InterruptedException e){ e.printStackTrace(); } System.out.println("]"); } } class Checking implements Runnable{ Race1 ob=new Race1(); String s; public Checking(String s){ this.s=s; } public void run(){ synchronized(ob){ ob.show(s); …

Member Avatar for vantrendin
0
247
Member Avatar for Shibbir Khan

So i've got a for loop that's reversing every other word in a string. I can't determine which condition is causing this. I've spent a good amount of time staring at this and the API, to no avail. Anyone have any idea why it's not working? String newMessage; StringBuilder stringBuilder …

Member Avatar for JamesCherrill
0
165
Member Avatar for moaz.amin.37

when we create a thread like this class Run implements Runnable{ public void run(){ //You code } } class Helloworld{ public static void main(String args[]){ Thread t1=new Thread(new Run()); Thread t2=new Thread(new Run()); } } in above code thread t1 and thread t2 is creating in `main()` method its mean …

Member Avatar for JamesCherrill
0
272
Member Avatar for ajharul

Hi all! This is my frist discussion. I'm shearing you a very helpfull website that helping me to learn HTML,CSS,Javascrift online. It's w3schools Wish it will help you.

Member Avatar for shashikumar s g
0
221
Member Avatar for Stefce

Hello i have a little problem over here im trying to make a mouse listener and on mouse click the ball to come to the mouse pointer... i have maked a small "game" which is not bunch of confusing code... i have maked the ball to be controlled by the …

Member Avatar for Stefce
0
2K
Member Avatar for laavanya

What does this mean ? Statement st=con.CreateStatement(); how method of Statement interface is accessed by Connection interface reference con ? please help me to understand the concept...

Member Avatar for JamesCherrill
0
365
Member Avatar for Trevor_4

double hours=0, rate=0; double Federaltaxes, Ficataxes, Statetaxes; double netpay=0, grosspay=0, totaltaxes; if (hours <= 40){ System.out.println("how many hours did you work"); hours= input.nextDouble(); System.out.println("what is the rate you get paid"); rate= input.nextDouble(); grosspay= hours * rate; System.out.println("the gross pay is:" + grosspay); Federaltaxes= grosspay * .20; System.out.println("Federal taxes are:" + …

Member Avatar for oussama_1
0
91
Member Avatar for James_30

Changed properties on the embedded derby db. protocol, driver etc. org.apache.deby.jdbc.ClientDriver ... A connection could not be established

0
74
Member Avatar for Jonathan_7

Hello I am an absolute begginer and am working on a paint calulator program. I am trying to return the price from the paintformula ex: price = paintFormula(wallArea,price,height,length,width); or paintFormula(wallArea,price,height,length,width);. When I call the method I keep getting errors like: PaintCalculator2.java:33: error: variable price might not have been initialized. import …

Member Avatar for JamesCherrill
0
163
Member Avatar for karan parmar
Member Avatar for DawnofanewEra

Hello, I got implementation of Data Encryption Standard implementation in java (internet code) but the only part that I cannot understand is the S-Box which shown below. I know how S-Box works but I don't understand this code especially &0x20 and stuffs like that. The S-Box takes a 6 bit …

Member Avatar for rubberman
0
2K
Member Avatar for Ritesh_4

Hi I have a code in java to generate a sitemap xml, and to get the last modified date using the following line of code: `oPrint.println(" <lastmod>"+ doc.getLastModified().toString()+"</lastmod>");` The output in the browser when calling the xml file is `<lastmod>23/05/2014 16:48:24 ZE4</lastmod>` which is in "dd/mm/yyyy"format. However, from this link, …

Member Avatar for Ritesh_4
0
791
Member Avatar for kayleigh0411

There are no errors when I compile the program, but when I run it and use the "Enter" or "Clear" buttons, they do not work. ----jGRASP exec: java IncomeTax Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at IncomeTax.enterJButtonActionPerformed(IncomeTax.java:182) at IncomeTax$1.actionPerformed(IncomeTax.java:125) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.Component.processMouseEvent(Component.java:6525) …

Member Avatar for stultuske
0
2K
Member Avatar for DkgMarine

hey guys, so i just started learning java and had some error in my first array code. Error: Could not find or load main class Being. I use eclipse if that helps, because i read that these problems might be that ecplise cannot find the class, so just making sure …

Member Avatar for stultuske
0
170
Member Avatar for DkgMarine

hey guys, -So in case 2, i'm trying to have the user to input elements (N,Y,P,D,G) only with specific Array location. I used switch inside a switch, but how do i re-loop if he enters wrong elements? -in case 3, i'm trying to print the whole 2D array, but the …

Member Avatar for oussama_1
0
1K
Member Avatar for OMDYD

hi guys am new please i your help to debug the error with this code am working with String output="Sum of the Addition of "+num1+" "+num2+" "+num3+" "+num4+" Sum

Member Avatar for oussama_1
0
412
Member Avatar for redkowloon

Hi , my friend pass this coding to me , to change it on few things , i try to change it first , to make a while looping ... loop for once but i get error , then change the input from number+letter to letter+number , still got no …

Member Avatar for redkowloon
0
123
Member Avatar for moaz.amin.37

import java.io.*; class ConsoleInput{ public static void main(String ss[]) throws IOException{ InputStreamReader isr=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(isr); char c=' '; System.out.println("Enter Characters And q to Quiet"); do{ c=(char)br.read(); System.out.println(c); }while(c != 'q'); } } in upper code this line `c=(char)br.read();` get string from user at this point user enter some …

Member Avatar for JamesCherrill
0
267
Member Avatar for moaz.amin.37

Hello every body i have a problem with Scanner class.So my question is that when we use `BufferedReader` or`InputStreamReader` to reading and writing input and output then we use `close()`method to close the stream but in the case of `Scanner` why we do not close the stream this is my …

Member Avatar for JamesCherrill
0
161
Member Avatar for Slavi

Hey guys, another one that I got stuck on(Although I passed 4000 points, soon to be on the leader board!:D) ... so here is the idea I have an input array for example {1,2,3,4,5,6,7} and an int number for example 10; so what I have to do is return all …

Member Avatar for Slavi
0
278
Member Avatar for Parth_1

hello all, As i am developing a final year project of my curriculum.\ I need some guidance for my project. My project is "**Face detection from digital image**". Also i want to develop this project in Java Programming language. As i am new to image processing domain, i want to …

Member Avatar for Parth_1
-1
126
Member Avatar for Slavi

Hey guys, I need to produce an output such as {{0,0,0,0,0}{0,0,0,0,0}{0,0,0,0,0}{0,0,0,0,0}{0,0,0,0,0}}; I have no input paramethers so I assume I need to have int[] array= {0,0,0,0,0} and then make 2d array of it? I tried int [][] arrayOfSets = new int[0][25]; int [] a = {0,0,0,0,0}; for(int i=0; i<1;i++){ for(int …

Member Avatar for oussama_1
0
114
Member Avatar for Kris_3

Hi guys, so I started learning Java 2 minutes ago and I have already encountered an error. The error is Error: Could not find or load main class apples.class and I get it after I use the cmd to type java apples.class . Here is the code I compiled to …

Member Avatar for Slavi
0
521
Member Avatar for chewie20601

Hi I am new to Java/netbeans. I have been working on a school assignment to create a commission calculator. I have it done I believe but, have some errors. Please help. /* * To change this license header, choose License Headers in Project Properties. * To change this template file, …

Member Avatar for chewie20601
0
432
Member Avatar for DawnofanewEra

Hello. I've written a simple program that will once read text into a file and then append some other text when it starts reading again. In other words, adding text to an already existing one. My program doesn't do that but instead it keeps overwriting the older text. How can …

Member Avatar for TylerD75
1
214
Member Avatar for thewalrus

Client code import java.net.*; import java.io.*; /** * This example illustrates the basic method calls for connectionless * datagram socket. * @author M. L. Liu */ public class Example1Sender { // An application which sends a message using connectionless // datagram socket. // Three command line arguments are expected, in …

Member Avatar for TylerD75
0
370
Member Avatar for silvercats

A class gets a rapidly changing integer from another class. As it changes so fast, I wanted to perform an action only when this number is stabilized. Like if the method receives the same integer value during 3 seconds, then perform an action, otherwise ignore it as it changes too …

Member Avatar for milil
0
158
Member Avatar for jordan.nunnery.75

Create as program that calculates the current grade in a class, the program should ask for 5 grades as well as the toal point value. I am new to programming and need help!

Member Avatar for jwenting
-1
164
Member Avatar for patricia28

import java.util.Scanner; public class assignment8{ public static void main(String[] args ){ Scanner s = new Scanner (System.in); double a,b,c; double discriminant, r1, r2; System.out.print("Enter a, b,c"); a=s.nextDouble(); b=s.nextDouble(); c=s.nextDouble(); discriminant= Math.pow(b,2)- 4*a*c; if(discriminant>0){ r1=(-b + Math.pow(discriminant,0.5))/(2*a); r2=(-b+ Math.pow(discriminant,0.5))/(2*a); System.out.print("The equation has two roots"+ r1 + "and"+ r2+"."); }else if(discriminant==0){ r1= …

Member Avatar for ddanbe
0
256
Member Avatar for sciprog22

Hello, Could you explain the output for the program below? Is the output specifying a reference of the Scanner object in RAM (I don't see any hex hash) or something else? Thank you! import java.util.Scanner; public class ScannerTest { public static void main(String args[]) { Scanner input = new Scanner(System.in); …

Member Avatar for sciprog22
0
180

The End.