I am working on a game project. Whenever we are starting our game application in production, it works perfectly around 3 days after 3 days, CPU utilization is increasing upto around 95% to 99% and application stops to respond. Before 6 days, I started application again and we doubled our Perm Gen memory size. The same problem happened but it happened after 6 days.
Now, i am not able to relate CUP utilization to Perm Gen memory. Is Perm Gen memory effect CPU utilization?
In carrying out my little game I made a panel "Winner" in which I have two JButton plus I would like to add a blinking text to indicate the victory of the player("You win!"). Currently this text is static, designed by the function drawImage. How can I make it "flashing" maybe alternating the vision of the text (which I present in two different colors)?
for (int w=0;w<bi.getWidth();w++) { for (int h=0;h<bi.getHeight();h++) { int color = bi.getRGB(w, h); color = color << 5; bi.setRGB(w, h, color); } }
I am using a solid green image so
11111111000000001111111100000000
I just wanted to see how it looked so bumped it over 5 places (obviously changing the color). To my surprise, there was no added transparency. I mean moving it to the left would make the alpha:
11100000
I am thinking that setRGB() doesn't effect alpha. Is this accurate?Tested it and in fact setRGB has no effect on the alpha bits. So now the question is how can I gain access to them. I am going to look into the writable Raster API. Perhaps, I can also use a modified awt to access directly OS data.
I have one jsp page in which I have listed some service records fetched from Database. I have made one of the column, for eg. Service ID to be link, which should display all the details of that service when clicked. I want those details to be displayed in lightbox. I tried doing it but when any service ID link is clicked, it displays same(First Service in record) service details.How do I pass reference of that current service to lighbox effect.
This isn't solely related to java.awt.Color, it's more of a question on how to store methods or redirections to use methods on any value passed in. To explain my question I'll describe a scenario:
ClassA is an instanstiatable class
ClassA has an instance of ClassB called cB
ClassA has methods of affecting cB
ClassD is also an instanstiatable class
ClassD has an Array[x][y] of instances of ClassA
I want to create a ClassE which I would initiate it with references to ClassA's methods or their actual methods and then I can use ClassE to easily transform ClassD's instances of ClassA by the same methods.
What I'm actually doing:
I made a class called GameColor, it has methods like changeHue, setRed, setHue, changeBrightness, setSaturation etc, these methods affect an instance of java.awt.Color in the GameColor class instances, so like they can change the hue or set it with changeHue or setHue etc...
Now I want to do something like perform a single method on a whole BufferedImage, on each of it's pixels RGB. So, I'm thinking of creating a GameColorEffects class which I store references or actual methods of GameColor like changeHue, and then I use GameColorEffects somehow to change a whole BufferedImage more efficiently, what's the most efficient way I can store methods or their reference of GameColor and then later apply them on each pixel of a BufferedImage using GameColorEffects. So all I do is initiate GameColorEffects with methods or reference from GameColor, and then I can apply it to easily transform each pixel.
I have a UI widget, like a table view for example, displaying real-time data. This table can be configured - so it has many properties. The way I would like to do so, is to have a small 'configure button', once clicked, would rotate the entire table along its y axis, and display another panel with checkboxes etc... So effectively, the hidden properties panel is revealed by rotation.
I am trying to understand the effect of calling real business logic from the test class. If I have a test class that call the service method which make update to DB. Is DB really changes through test class?
e.g.
Java Code: @Test public void testUpdate() { MyDto myDto = new MyDto(paramters to create new myDto object); //creating new dto object myService.updateMyData(myDto); //passing new dto object for update (DB record really changed??) MyDto testDto = myRepo.find(myDto.getKey()); //get record for the corresponding key assert testDto.getSomeProp() == myDto.getSomeProp(); //what testDto.getSomeProp() return? new value send on myDto or old value from DB? } mh_sh_highlight_all('java');
As you can see instead of displaying the champion name it is displaying the memory location and I do not know how to fix it.
class Champions { String name; Champions [] weak = new Champions [3]; Champions [] strong = new Champions [3]; String [] items = new String [3]; public static void main (String [] args) {
For some reason my code returns the memory address of the array when its a print statement with a string, but it works fine when its in a separate print statement all by itself. Why? Do I need to create a toString method that converts a char array to a String to something? The reason why I ask that is becuase on Eclipse line 10 has a warning stating "Must explicitly convert char[] to a String".
public class Ex { private String word; public Ex(String word) { this.word = word; } public char[] Display(){ char[] wordChars = this.word.toCharArray(); return wordChars;
[Code] .....
Result:
Hello world The word is: [C@1db9742
I also tried this, knowing that it's a long shot, but that didnt do anything...
public String toString(){ Ex ex = new Ex(this.word); char[] word = ex.Display(); String updated = word.toString();//counter intuitive? return updated; }
So I have that traditional memory game homework assignment and for some reason I can't figure out how to put the codes in order. I can't figure out the arrangement to make it work. So far I have
import java.util.Random; import java.util.Scanner; public class MemoryGame {
I had a question about data structures. For the insert method of a linked list, the 'node' object is declared in the insert method. So doesn't the 'node' get destroyed as soon as the closing brace of the insert method is encountered? How do all the nodes continue to occupy memory?
Making a memory game where you click a square it turns over an image and you match the two pretty simple. My issue is my images are not displaying and I am not sure why everything looks correct to me.
when running Eclipse, roughly 250k memory is used by it?In my Task Manager, it says: javaw.exe00265,000 KJava(TM) Platform SE binary.The value of 265,000 K is of course fluctuating, but around this value. Btw, this is when Eclipse is just running in the background, without even any java programs running in it. Is this normal memory usage by Eclipse?
"A common memory matching game played by young children is to start with a deck of cards that contain identical pairs. For example, given six cards in the deck, two might be labeled
1, two might be labeled 2 and two might be labeled 3. The cards are shuffled and placed face down on the table.
The player then selects two cards that are face down, turns them face up, and if they match they are left face up. If the two cards do not match they are returned to their original position face down. The game continues in this fashion until all cards are face up.Write a program that plays the memory matching game. Use sixteen cards that are laid out in a 4x4 square and are labeled with pairs of numbers from 1 to 8. Your program should allow the player to specify the cards that she would like to select through a coordinate system.For example in the following layout:
All of the cards are face down except for the pair 8 which has been located at coordinates (1,1) and (2,3). To hide the cards that have been temporarily placed face up, output a large number of newlines to force the old board off the screen.Use 2D array for the arrangement of cards and another 2D array that indicates if a card is face up or face down.Or, a more elegant solution is to create a single 2D array where each element is an object that stores both the cards value and face.Write a function that shuffles the cards in the array by repeatedly selecting two cards at random and swapping them.
Note:To generate a random number x, where 0<= x <1, use x=Math.random();.For example, multiplying y six and converting to an integer results in an integer that is from 0 to 5."I have been thinking about the algorithm and design of the question for a few hours.
Started ok i guess? But when it comes to the save and get methods im totaly lost.. (See the code)
import java.util.HashMap; public class Model { HashMap<Integer,Long> m = new HashMap<Integer,Long>(); Integer value; Long result = 2 * computePower(value-1); public long computePower(int value){ if(value <= 0 )
Basically we have to create a calculator that it will have to keep track of the current value, and do the functions that the calculator uses.
But I have it working for the most part, but the current value does not keep...
The double " currentValue " Must stay private.
import java.util.*; public class MemoryCaluclator { private double currentValue; public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int answer = 0;
I understand how to write a child object. I know what can access what and the order of execution of each statement, including fields, initialization blocks, and constructors. I know what will be inherited by the child and how private fields and methods are not inherited. I also know that private fields and methods in Parent are still accessible indirectly through constructors, and non-private methods. I know how to use super() and this() with or without parameters. I know when super() will be automatically inserted by the compiler and how the Object class will always be the ultimate parent class. However, I have not been able to find an explanation of exactly (or even approximately) how all this is actually put together into an actual object in memory.
For instance, if Parent.field is private and Parent.fieldGetter() is public then Child inherits fieldGetter() and can call it directly as if it is a member of Child. In fact other classes can call Child.fieldGetter() with no clue that it is not an actual member of Child. But, if fieldGetter() is now part of Child and Parent was never actually instantiated, then how is Parent.field available for Child.fieldGetter() to read? In fact, how does Parent.field exist at all? Where is it stored? (OK, I know, "on the heap.") But I want to know what it is associated with in memory. Is it treated like part of Child? Is there really a Parent object on the heap and Child simply contains references to the parts of Parent that it inherited? What?