The other day I decided to write an implementation of radix sort in Java. Radix sort is supposed to be O(k*N) but mine ended up being O(k^2*N) because of ... |
In Java, is it possible to clear a bit using bitwise operations?
|
In the documentation for isValid(int) from java.sql.Connection (an interface):
http://java.sun.com/javase/6/docs/api/java/sql/Connection.html#isValid(int)
it states that it will throw an "SQLException if the value supplied for timeout is less then 0".
Should implementors read this ... |
Correct the following erroneous definition of method getAge()
public void getAge()
{
return age;
}
Paste your answer in here:
public int getAge(int age)
{
return age;
}
Mark: 0 out of 1
Comments:
* Test ...
|
We have a Java application which needs to communicate with a peripheral device over Virtual Serial COM port. We use the RS232 Java COMM API (javax.comm.properties, comm.jar, win32com.dll) to achieve the ... |
System.out.println(
s + ", long: " + l + ", binary: ");
System.out.print(" ");
for(int i = 63; i >= 0; i--)
if(((1L << i) & l) != 0)
...
|
i want to multiply two 512 bit integers in java and store the result.suggest some method to do this.
|
|
For example, I have the binary number 1011 which is equal to decimal 11. I want the reverse bit's location such that it become 1101, which is decimal 13. Here is ... |
sorry Friends i did a mistake. I have did this mistake again. am really very sorry.
this is the Issue.
I have a time range like
int Starttime = 2 which ...
|
I want to mix to multiple ULAW samples together in Java. Is there a way to do so without converting to PCM? Im trying to do a 8000Hz 8bit VoIP app. ... |
Is there a way to run or simulate running Java statements (kind of like IDLE - the Python GUI) without compiling and running the executable? I want to quickly test statements ... |
Let me start by saying I have never really worked with bits before in programming. I have an object that can be in 3 states and I want to represent those ... |
What do those lines of code stand for?
payloadType = header[1] & 127;
sequenceNumber = unsigned_int(header[3]) + 256*unsigned_int(header[2]);
timeStamp = unsigned_int(header[7])
...
|
I want to write to a file or a string in the finest control which is supposed to by bit-by-bit control.
For example, '00101111' (2Fx) is expected to be written to ... |
Is there a preferred order to the bits in a bit stream (where a bit stream is somewhat analogous to Java's Input/OutputStream, but provides bit-level granularity)?
I've read that the ... |
I have 16 bit PCM audio and I want to convert it to 8bit PCMU. As far as I know 16bit to 8 bit conversion is easy - just drop the ... |
Is there a Java library for making Bitly requests? I'm looking to both shorten links, and look up info on clicks, etc. of links. Yes, I know ... |
I have a problem with flag bits.
I have an int variable to hold flags. first i set some flags to that variable. later i need check how many flags were set ... |
I have a simple question - I need to write a function for my program to change the 3rd bit of a given byte.
I wrote those lines :
public byte turnOn(Byte value)
{
...
|
So I have been given a C program, which I am trying to make more portable by translating to Java, which has been going well. However, I have run into a ... |
Let's assume that we have int x = 371, that is in binary format 101110011. I want to find the index of the left-most unset bit (in this case 7), and ... |
So I have the following homework, but I don't understand exactly what the process is. Has anyone seen this question before or actually understands what the logic should be? I ... |
I want to know which value the first bit of a byte has.
For example:
I have byte m = (byte) 0x8C;
How could I know if the first bit is an 1 ... |
I'm trying to make some bit operations in Java for applying masks, represent sets etc.
Why:
int one=1;
int two=2;
int andop=1&2;
System.out.println(andop);
Prints a "0" when is supposed to be "3":
0...001
0...010
_______
0...011
And how can I get that ... |
I need direction to get started with a project. I have a binary file. Out of this file, I need to parse data. Now, I know length of each data; however, ... |
I created an SSL server cert at CAcert. When I try to fetch a page from this server from a Java program (below), I get
Exception in thread ...
|
Hello everyone, I was just wondering if someone could help me figure out how to write a function that rotates bits in Java while carrying over. For example, if I had : int test = 0x41; //00000000000000000000000001000001 <-- 65 and I wanted to rotate to the right by 3( could be any number, just an example), then I want the number ... |
|
Hello I have one html form in which i have two fileds,one username and another is password and one submit button. After entering this value ,i press submit button.On press of submit button i call one servlets,in servlet programme i have a databse connectivity,as well as accept value from HTML form using request.getParameter() mehtods and compare with my database table(In database ... |
My title probably does not accurately reflect my problem, so hopefully I can explain it without causing anybody's eyes to glaze over, or drool to drip from the corner of their mouths. I am comparing two text files, which seems simple enough, but after messing with it for a couple of weeks, I am finding it harder to accomplish that I ... |
probably solving is easier...because it can be done with a brute force/recursive algorithm (try and error) when you create a sudoku, then you need to make sure that it can be solved... which you do by solving it.... as stefan said: think about a datastructure... this will make it easier show us what you've done so far and then we can ... |
This comes from the book "Java After Hours", cool book by the way. I can follow most of the code, and I am playing with it to match some design patterns for practice and make it a bit more interesting. This part I can't follow or find a decent explaination. public class Aquarium extends Frame { public Aquarium() { super("The Aquarium"); ... |
While a strict reading of the JLS would imply that all three should be in the pool, in reality only one is. Which is fine because nothing in the program has any need at all for the substrings "tex" and "t" by themselves. The whole thing is resolved at compile time as a single string "text", and that's what gets stored. ... |
I'm currently studying artificial neural networks and coding a feed forward network in Java. I have coded a lot of it but i'm a bit stuck now as i ain't done java in a long time. I have commented what i need to do as i understand what its doing, just not how to code it. Any ideas - i have ... |
|
Hello everyone! I need some help with bitpatterns. I've read a chapter about it in java 2 study guide and I've altso red cat and mice in campfire. I have some question though. This is how I think it is. When shifting >>> the bitpattern will be filled with 0. When shifting << the bitpattern will be filled with 0. When ... |
|
Hey there. How does one cast a Float object to a String object or is that possible at all. I have a method which takes a string as argument and logs the string to a file. My program returns the scale of a map in a float format. I need to take this float value and output it to my logfile ... |
|
hello, i have the following problem: consider implementing the following properties of the class fruit which has the following properties: fruit.isTasty, fruit.isJuicy, fruit.hasPeel i want to store these boolean properties in a single byte. i would presume that one goes about doing this by delcaring the following constants: TASTY = 2^0; JUICY = 2^1; PEEL = 2^3; and then a bitmap: ... |
I think you basically understand what an int is. The one new detail that was mentioned above is that an int is 32 bits long. A 'literal' is a hardcoded value right in the source code. For instance, in... int myInt = 41; char[] myArray = {'S', 'h', 'y', 'a', 'm'}; String myString = "Murarka"; ...the 41, 'S', 'h', 'y', 'a', ... |
This is the program... public class simple { public void display(Object obg) { System.out.println("in display with OBJECT argument"); } public void display(String str) { System.out.println("in display with STRING augument"); } public static void main(String [] args) { simple s = new simple(); s.display(null); } } While executing it gives output... "in display with STRING augument" Why? Actually i was expecting display(Object ... |
Hi I need help understanding some code. The code is used to convert a byte to a hexadecimal. When converting from a byte to an int why do you have to do a logical AND with 0xFF. For example: int i = 'A' & 0xff; Also what will the following operation do. I know it does a right shift of 4 ... |
I was inspired to solve the problem posted by someone recently about bit operations. However, I am afraid to ask for too much help because I really don't want to just post the answer out here for that person to steal. So I am going to try to ask for very specific help on a couple things I'm not exactly sure ... |
Hi, i am working on a project in which i have to create a data structure of of bits(say 232 bits of data, 29 bytes). In this 232 bits, 0 to 2 bits represent something,3 to 6 bits represents something,......229 to 231 bits represent something. This data of 232 bits is used and is encripted. Can anybody please suggest how to ... |
|
Because shift operations do not produce a single bit. Look at this old thread. If you want a particular bit try/** * Gets the nth bit from the right, where the least-significant bit is no 0 and the most-significant bit is no 31. *@param input The number to investigate *@param n How many bits from the right to go to find ... |
|
Java histogram program.. bit of help required please? hey guys im having trouble at moment with this program the aims is to generate random numbers 80 times between 1 and 100 and generate a histogram in category they fall in ie 1-10 and so on.. not only that i need for every number a single * should be entered into the ... |
1. import java.io.*; 2. class Ex11 3. { 4. 5. public static void main(String[] args) 6. { 7. Console console=System.console(); 8. System.out.println("please write a sentence"+" "); 9. String Str; 10. Str=console.readLine(); 11. 12. 13. System.out.println("please write another sentence"+" "); 14. String Str2; 15. Str2=console.readLine(); 16. char c=Str.charAt(0); 17. 18. 19. int n1=0; 20. int n2=0; 21. while (n2 |
Hello everybody! I would like to apply the item 32 of the book "Effective Java" (i.e. "Use EnumSet instead of bit fields") to a particular case: I have to deal with an application which gives me an integer number representing the bit field from which I should build my Set.. In the old version of my class, I have something like ... |
Hi All, Well, I have been studying Java for just over a month and I have almost finished my first program. But as you see I am stuck. Below is a copy of the code for a program I wrote MANY years ago in Tandy Basic, written in Java. I don't understand why my System.out.println call won't work. A word of ... |
Hi All, Well, I have been studying Java for just over a month and I have almost finished my first program. But as you see I am stuck. Below is a copy of the code for a program I wrote MANY years ago in Tandy Basic, written in Java. I don't understand why my System.out.println call won't work. A word of ... |
What browser are you using? I have firefox. after clicking the one 'on the far left', it asked if i wanted to save it, then saved it to where my browser is configured to save it. It's possible IE (if i recall correctly) gives you the option to run it, which may simply store in in some temp dir and then ... |
Coming from a c++ background i was surprised to read that protected fields in a class were accessible to the instances of the class. I was however a bit confused b/w the default (no access modifier) and the protected modifier. Could anyone please give a simple explaination on their difference. I did look up on the internet and even oracle http://download.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html ... |
Im a bit confused (Java in General forum at JavaRanch) A friendly place for programming greenhorns! Register / Login Java Forums Java Java in General Im a bit confused Post by: Spas Dimitrov, Greenhorn on Jul 09, 2011 20:49:08 Hi try to run a simple demo application from Jedit which is started by using build ant file and groovy. ... |
I don't think that a WebStart application has any such attribute. Java applications are "write-once, read-anywhere" which at least means that they will run equally well in 32-bit and 64-bit environments. Distributing them via WebStart doesn't affect that in any way that I can see. So what problem caused you to ask this question? |
|
Hello everyone! I've noticed that there are many new members that are interested in Java gaming. I'm currently busy with a space game called "Eath's Belt". I think that some members on Java Forums might appreciate some pictures of what can be done with Java2D. The game has the ability to generate and draw scenery for my game. The game has ... |
Ive know started up programming again. My last try was in delphi where my best project was a security screensaver. Ive know decided to start up programming again and my choice this time was java whit netbeans and my project would be to rewrite the Security screensaveer and add any extra options i have figured out in my absence. Ive spend ... |
Java Code: import java.util.*; import java.io.*; public class Echo { String fileName; // external file name Scanner scan; // Scanner object for reading from external file PriorityQueue priorityqueue = new PriorityQueue(10); int counter = 0; int counter2 = 0; int counter3 = 0; double TimeStart = 7.00; double currenttime = 7.00; double timer = 7; int number = 0; String cool ... |
The following is what I am working on and the instructions are in the comments. I am having a hard time implementing the methods with loops because I have really no knowledge about loops. I have been reading up about them though. I have more knowledge about the syntax of a while than a for and would like to use a ... |
Hello, i know this is probably silly, but would someone be able to tell me why this code keeps erroring? and point towards the "+" sign in the compiler public class test { public static void main (String[] args) { int number=42; System.out.println("i want to create a program to seperate tens and units"); System.out.println("the number i am working with is ")+number; ... |
You are required to write a software application that manages an international outdoor car rally for thirty-two (32) cars. Thirty-two countries around the globe have a single representative team to this tournament. For each race, four cars compete per race. The best 16 race times goes forward to the second round, and the best 8 to the third round and the ... |
This is a code I wrote for Fundamental Java as an assignment. I wanted to round up the quotient of d and c and I found the answer on this website. But my question is how does the code that is colored red work? Thank you in advanced, Allspark //Allspark public class Lab02_Ex2 { final static int A = 7, B ... |
Hi all, I'm having a bit of a problem here... I'm making a simple MS Paint style program which allows the user to draw different shapes on a panel and edit the line thickness/width and the shape they'd like to draw using controls on a frame. I have my 3 classes, my frame(which includes my main method and user input buttons), ... |
/** * @return A HashSet containing the CommPortIdentifier for all serial ports that are not currently being used. */ public static HashSet getAvailableSerialPorts() { HashSet h = new HashSet(); Enumeration thePorts = CommPortIdentifier.getPortIdentifiers(); while (thePorts.hasMoreElements()) { CommPortIdentifier com = (CommPortIdentifier) thePorts.nextElement(); switch (com.getPortType()) { case CommPortIdentifier.PORT_SERIAL: try { CommPort thePort = com.open("CommUtil", 50); thePort.close(); h.add(com); } catch (PortInUseException e) { System.out.println("Port, ... |
I'm trying to create a simple program to view the individual bits any file consists of. I take this file in as an argument. I'm using a JTextArea within a JFrame to display the bits. The program works, but is dreadfully slow. Could I get a few pointers as to where the bottleneck(s) is (are)? I'm know the line Java Code: ... |
hi Im fairly new to Java and I have made a program. I just cant seem to make it count the characters or reset it to the start using the button. Also I'm trying to include a word counter within the program thanks. Also every time I run the code it just goes in a continuous loop here's the code: import ... |
Hey all, sorry if this isn't really the right place to post this, I wasn't sure so I thought this would be a good option.. Anyway, I'm trying to get Paros to run on my computer. It's a network monitoring tool. I have 64 bit win7, and the program won't run as is when I download it. I emailed the author, ... |
I've decided to try to learn the fundamentals of making a game. So, I started off by making a background and a character that moves. But then I wanted it so that when the character tries to go out of the frame, it's not allowed to. For the movement code, I used a tutorial that I modified to my needs because ... |
int[] lengths = new int[100]; characters int longestWord = 0; for(int i = 0; i < lengths.length; i++) { lengths[i] = 0; } try{ String line; int numTokens = 0; int numWords = 0; int numChar= 0; while ((line = textEntry.getText()) != null ) { String[] words = line.split(" "); numWords = numWords + words.length; for (int i = 0; i ... |
So I have a custom JLabel, and I want to paint a circle around it. The JLabel paints fine, but the custom circle code does not. I figured I could do it all in one class, instead having another class that draws the circle separately, I'm not sure if I can do this or not. Once again, the Jlabel with an ... |
I'm wondering if the code below can be refined a bit. I feel that some parts of it seems odd just looking at it. I know there are many ways to solve a problem. The comments before each for loop is the output of the code. I've studied Java a long time ago and I'm picking it back up again because ... |
Ok theres my code what im trying to do is substring my in file so that it will take a section of it out and put the rest in an out file. The problem is that my in file has a few lines and i do not know how to dubstrin g different linec can anyone help me? |
|
|
Hi, I'm facing trouble in getting the value of 7 bit number. It would be 128 base. if 7 bits are like that 0000001 0000010 ----result would be 82 my code is - public static String longTagVal(byte[] bytearr, int start) { int k = 0; int bits[] = new int[8]; while(true) { for (int i=0; i<8; i++) { bits = (bytearr[start+k] ... |
|
by two installers, I mean that if there are two different installers for intalling jdk one for 64bit machine with RHELx86_64 OS and other for 32 bit machine having RHEL x86_32 OS.? and secondly i was asking that when a 64 bit machine have jdk( will 32 and 64 create diffrence here too?) installed on it then jdk's /jre/lib/i386/libawt.so will look ... |
Ehh... Are you sure this ever worked? For starters, your main method is supposed to be static. Secondly, if it were static, then your main method would have to create an instance of this class in order to use it's non-static variables. I think that's it for now, I'll tell you if I think of anything else (It's just 2 AM ... |
So we are doing a program at school and I am a bit confused on what to do. For this program I have to make a game that sort of looks like this: XXXXXXXXXX TREASURE ISLAND XXXXXXXXXX 0 1 2 3 4 5 6 7 8 9 + - + - + - + - + - + - ... |
Short answer is, of course, no. The hardware itself most likely supports 8 bits as the smallest possible written value. However, you can of course fake it. You could buffer your bits, you could read in the chunk you want to write to, change the bit you want to write, and overwrite the chunk with your new value. I'm sure you ... |
i see one problem you read in a String from the keyboard, and then you try to compare it to a char. that wont work this is a char: 'a' this is a string: "a" so, either change it to compare strings, or get the char from the string, i think the method is String something = "a"; char firstChar = ... |
int ndx = ((JLabel)e.getSource()); I do not believe this is right, a good bit of the code is messed up. That's one of my major problems is that I cannot figure out how to get an integer value passed onto the swap method when a tile is clicked. I fixed the tile array problem, but I still get NullPointerException with my ... |
Hi guys, I'm currently taking a Java programming course dealing with data structures and I'm having a bit of a transition scare. My first year programming course was in C++ where we dealt with all of the into bits, including loops, classes, etc. My university is transitioning towards Java over the past few semesters so now my second year programming course ... |
|
|
How to unstuff them? Thank you for helping me out too.. But I need to unstuff them. What is the logic behind it. I am using the same logic but am removing 0 after I get 5 consecutive 0's. It's giving me error. ERROR in Utility.JNWBitSet.getBitValue: bitSetIndex = 47 ERROR: in Utility.JNWBitSet.setBitValue, value = -1 ERROR in Utility.JNWBitSet.getBitValue: bitSetIndex = 46 ... |
Struggling with the bithandling in java righ now. In the program I'm writing I'm communicating with a unit that gathers data for me. Depending on how the unit is configured it is sending different kind of data, and I have to handle that within my program. Therefore it is possible to query the "output" format that the unit is using, and ... |
|
Quick fix: Create a new inner class GaugePanel that extends JPanel and move the paint(g) method into paintComponent(g) of the GaugePanel. Better fix: Then move that inner class into it's own top-level class. You will need to move all of the relevant fields into that class and create methods to change some things like how much fuel is currently in the ... |
|
hi i need a bit of help plz i am new at java i am trying to put in a intergrs and output there total it i not know in advance how many integers there are in the sequence the sequence of integers is termiated by a dummy value of -999 this is what i have wrote so far i know ... |
Hello there and thank you for your help in advanced. I have a string of binary numbers and I need to use a 4 bit seeded random number generator for each bit. The thing is, I looked all around and was not able to find out how to do a 4 bit random number, not a 64 bit. Thank you so ... |
I'm trying to compile a simple "Hello World" application on the command prompt. I've got to the directory I want found the application I created, but after typing 'javac Hello.java', there is a pause and then it goes onto the next line and it's blank. Does this mean it's compiled correctly and that the problem lies with the code? |
I have created an application to read data from COM port. I connected a bar code scanner to the COM1 and open the port with 7bits and odd parity with 9600 baud rate. Then I configure the scanner to 9600 baud rate,8 data bits and odd parity. In that time also my application correctly read the data. But if I read ... |
Thanks for the reply, What you mentioned does make sense. However I'm not sure about 49 bit function: g(x) = x^48 + x^44 + x^40 + x^38 + x^36 + x^34 + x^32 + x^29 + x^27 + x^26 + x^22 + x^17 + x^16 + x^12 + x^7 + x^6 + x^3 + x + 1 Is the function. Therefore ... |
Hi everyone, So I'm trying to manipulate bits in a short value, but I've never actually messed with specific bits of a short before. I know a short is a 16 bit value, so I want to invert bits 11-8 ONLY...As far as I know, shifting bits is the way to go,right? I just want to grab bits 11-8 and check ... |
Basically the problem that I am trying to solve is that I would like to be able to use my Eclipse debugger on Windows and step into the Java SSL classes (JSSE) to help me debug SSL issues as well as to just understand the SSL process better. BTW I am familiar with (and use) the javax.net.debug=ssl|all system property to get ... |