Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
In the class java.lang.Math there are several trigonometric methods like sin, sinh, asin, similarly for cosine. I read the descriptions but couldnot able to understand their differences. So please help me on understanding their differences.
Please explain in simple way as I have already read the documentation and could not understand. So I need more simpler language ffrom the documentation.
I think that you need some mathematical background, to understand the functions you have listed. The wikipeida is a good start. I really doubt that someone will explain you the trigonometry in a single answer in a way that you will understand.
http://en.wikipedia.org/wiki/Trigonometric_functions - this is for the sine, cosine, arcossine and etc.
http://en.wikipedia.org/wiki/Hyperbolic_geometry - this is for sinh, cosh and etc.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm having trouble understanding the concept of using FFT to calculate frequency changes. I've been scavenging through a ton of articles on this concept but it's still confusing me. I found a Stack Overflow article about the steps to take to calculate the frequency, but I'm still a little bit confused on exactly what to do in Java.
Sounds like you need to start way back with some general concepts. An FFT is just a fast DFT. A DFT uses Fourier decomposition on a set of sampled data. So first you need to understand what a waveform is, what a sinusoid is, what a frequency is (and is not the same as a musical pitch), and how Fourier's theorem works to relate the two. Then how to compute a DFT on a window of a sampled waveform, and how to interpret the complex result vector. Then how to do it fast in Java.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am writing a piece of code that allows users to enter test scores. I then need to use the Math.max and Math.min to keep track of max and min and display the answer. I am not sure where I type that code or how I type that code.
Please let me know what pieces of the code would be helpful to post!
Thanks in advance!
Start by breaking down the problem into steps and figure out what you need to know. In your case you need to know four things:
How to get input from the console
How to compare values
How to conditionally change values
How to display things to the console
One and four you can search up pretty easy. Look into "Hello world" and other such starter programs for Java. Two and three you should look up "if" statements for Java. Hope this sets you on the right track.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
We have a number of issues that PMD has identified for us - a lot of which seems nit picky. I have a list below - may I ask the hive mind - if you had to pick the top 5 crticial rules out of below list what would they be?
I am trying to balance effort with criticality of what would be bad if it made to production.
Thanks in advance!
AssignmentInOperand
AvoidDeeplyNestedIfStmts
AvoidDuplicateLiterals
AvoidInstantiatingObjectsInLoops
ClassWithOnlyPrivateConstructorsShouldBeFinal
CollapsibleIfStatements
CyclomaticComplexity
EmptyIfStmt
ExcessiveMethodLength
ExcessivePublicCount
ImmutableField
InefficientStringBuffering
InsufficientStringBufferDeclaration
LocalVariableCouldBeFinal
LooseCoupling
MethodArgumentCouldBeFinal
NcssMethodCount
NPathComplexity
PackageCase
PositionLiteralsFirstInComparisons
SignatureDeclareThrowsException
SingularField
TooManyFields
UncommentedEmptyConstructor
UncommentedEmptyMethod
UnusedImports
UnusedPrivateField
UseSingleton
Yikes! One could argue that all of these point to a code base that really needs refactoring to improve reusability and future maintainability, and none of them are "nitpicky". Keep in mind that static analysis is making recommendations, and that you're the best judge of what's good for your code, your customers, and your budget.
But if I had to pick a few to focus on first, I'd go after those that indicate deeper architectural problems: AvoidDeeplyNestedIfStmts, CyclomaticComplexity, LooseCoupling, TooManyFields, and ExcessiveMethodLength. Just my $0.02...
PMD or any other static code analyzer helps you to write better code. There are certain parameters/rules against which your code is analyzed. Anything critical will be catch by java compiler itself. These tools simply helps you to find few flaws in your code and format your code in a cleaner way.
The more of these you fix, the better and cleaner your code will be. If you think a rule is too "nitpicky", and you don't want it to be reported by PMD, then remove the rule from your rules.xml file. PMD also allows you to place comments in your code to ignore that one occurrance.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
When I practice to take the OCJP exam, I see that the questions that I'm suppose to practice on are often trick questions which try to fool my into answering wrong. The example is from the Bathes / Sierra book and a typical trick question is:
Now I wonder if you can tell me if the questions on the real exam also often are trick questions like these or if the actual exam has another style, or if this is close to what I should expect?
The given example is not tricky. It simply measures that whether you know the difference between constructors and methods. Constructors and methods might have the same name, it is not a compilation error.
The exam may contain questions like these to trip up the participants. However, you should keep in mind that every question in the exam is just for measuring your ability and knowledge in certain exam objectives. You should ask yourself while reading the question: "What objective might this question be measuring?"
Now I wonder if you can tell me if the questions on the real exam also often are trick questions like these or if the actual exam has another style, or if this is close to what I should expect?
The point of grilling you through such questions is to help you get your defenses up. This is not a trick question like #Juvanis has pointed out, but such questions will help you develop a pattern to identify faults in code. Usually a pattern begins to emerge and your brain starts to analyze the code like so...
Do all the necessary imports exist and are they correct ?
Are non-static variables accessed from a static context ?
Check method return values and return type.
Check autoboxing / unboxing errors.
... and so on
The real exam is easier. However if you prepare with harder questions, the chances of succeeding are better.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
What are some good data structures for keeping track of agents in a two-dimensional, spatial simulation?
I've seen some references to quadtrees (which I understand) and kd-trees (which I don't understand very well).
I'm looking for something through which an agent can efficiently say, "I know my location, and I would like to know which agents are near me (within a certain radius of myself)."
Examples (pseudo-code is fine) would be greatly appreciated.
I'm working in Java.
Well, I'm not sure exactly how it is implemented, but the MASON toolkit uses a discretization algorithm that places agents that are close to one another in the same "bucket" of a hash table. It makes for very fast lookups, as only a few of these buckets have to be checked for each query.
The best thing for you is probably to take a look at the source code here:
http://code.google.com/p/mason/source/browse/trunk/mason/sim/field/continuous/Continuous2D.java?r=529
I have found something called a Bucket PR Quadtree.