Finding Necessary Imports

Feb 8, 2014

where to find the following import the files?

import de.uos.fmt.musitech.data.score.NotationStaff;
import de.uos.fmt.musitech.data.score.NotationSystem;
import de.uos.fmt.musitech.data.score.NotationVoice;
import de.uos.fmt.musitech.data.score.ScoreNote;
import de.uos.fmt.musitech.data.structure.Context;
import de.uos.fmt.musitech.data.structure.Note;
import de.uos.fmt.musitech.data.structure.Piece;
import de.uos.fmt.musitech.data.structure.linear.Part;
import de.uos.fmt.musitech.score.mpegsmr.Attributes;
import de.uos.fmt.musitech.utility.math.Rational;

View Replies


ADVERTISEMENT

Use Of Imports

Mar 25, 2014

I am a bit confused on the use of imports. I am reading a book on java and in one of their examples it starts a program with;

import java.io.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

The question I have is on the awt import.If I have import java.awt.*;I assume that that will include all I need under the awt directory but the next line, import java.awt.event.* why the java.awt.*; does not include the .event.*; directory as well?

View Replies View Related

How To Manage Imports

Feb 27, 2015

My first Java project contains 30+ imports, all of which are for specific classes -- I'm using NetBeans and whenever I instantiate a new, unimported class I just click on the "light bulb" and tell it to import. I'm only now starting to worry about code management and conventions.

As you can imagine, many of these imported classes live in just a few packages, like awt and file.nio. It's starting to make my code a little cluttered. In the real world, what is the convention for import statements? My instincts tell me I should just import using the .* wildcard, but how do professionals do it? If an experienced programmer were to pull my code from Github, what would they want or expect to see in the import lines of code: a bunch of specific imports, or wildcard imports?

View Replies View Related

Wildcard Imports May Lead To Ambiguities?

Jul 31, 2014

The followings are what I see just now.....
//******************************************
Ambiguities

Wildcard imports have one problem though: they can lead to ambiguities when classes with the same name exist in two packages you import via wildcard.

Imagine the following two imports:

import foo.*;
import bar.*;

Now you want to use the class foo.Node but there is also a class bar.Node. Now you need to use non-wildcard imports to resolve the ambiguity that would happen otherwise.

View Replies View Related

Adding Imports - Change To Swing Format

Apr 20, 2014

I made a game but i didn't add imports, i have been told i need to have imports and it needs to be in a normal swing format or it will not pass . How to change my code to swing format?

My code is

public class TextTwist extends javax.swing.JFrame
implements java.awt.event.ActionListener

// hard code, should be picked from a Problem class
private String[] letters = {"F","O","C","I","E","F"};
// hard code, should be picked from a Problem class
private String[] solutions = {"ICE","OFF","FOE","FOCI","OFFICE"};
 
[Code] ....

How do i get the program to move on to the next one String?

View Replies View Related

Finding A Value In 2D Array

Dec 3, 2014

I have assigned random numbers to an 2D array, and I had to write a method that prompts the user for a number between 100 and 200. If that number is in the array, it should return 1. If not, 0. It only stays 0 though, even when the number matches one of the numbers in the array.

public static int Findit(int[][] numbers, int guess) {
int Findit = numbers[0][0];
int i = 0;
int x = 0;
boolean found = false;
for(i=0;i<numbers.length;i++)

[Code] ....

View Replies View Related

Finding GCF Of Two Numbers

Nov 18, 2014

I have been struggling to find out what to change to allow my code to find the GCF of two numbers. The instance variable in the class is num, so I need to find the GCF of a and num. It works for the example problem of 25 and 15, returning 5, however it will not work for other problems.

public int findGCD(int a)
{
int result = 0;
int newNum = num;
if ((a > num) && (a % num != 0))

[Code] .....

View Replies View Related

Finding A String In Array

Oct 4, 2014

My current problem is when im trying to choose case 2 and call markItemOnLoan i cant seem to find the title i want after i enter a few. I will include all of my code but i have mentioned what I am currently stuck on :

import java.util.Scanner;
public class Library {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
MediaItem mCall = new MediaItem();
Library call = new Library();// makes instance

[code]....

View Replies View Related

Finding Sum Of Two Dimensional Array

Apr 1, 2014

How to declare a 2 dimensional array of interger of size 10 by 10. and then set every element of the array to 3. After this I need to add up all the element in this array and return the value.

final int ROWS = 10;
final int COLS = 10;
int[][] foo = new int[ROWS][COLS];
for (int i = 0; i < ROWS; i++){
for(int j = 0; i< COLS; i++){
foo[i][j] = 3;
}
}

This is what i have done so far(not 100% if is correct..) but how to add up all the array.

View Replies View Related

Finding Space In String

Jan 19, 2015

I have an assessment for college, the part of my code that im struggling with is the part where the user enter their first name followed by a space and then their second name. I m using ---------------fullname = JOptionPane.showInputDialog("enter your firstname followed by a space then your second name " ); ------------- to capture this. the issue is if the user only enter 1 name I need to output an error. the issue is I cant find a way to tell if the user entered a second name. This is what I have so far:

public void makename() {
// makes an inputbox to ask their name
fullname = JOptionPane.showInputDialog("enter your firstname followed by a space then your second name " );
 //separates the first and second name into 2 strings in order to make the username
 
[code]....

The problem is it accepts anything I type in without causing an error. What should I type in to stop this? ive tried anything but I cant find a way to tell if a surname has been entered or not.

View Replies View Related

Finding The Right Import Statement?

Feb 13, 2014

Often times i don't remember which package a specific class (like ArrayList) belongs to. Is there an easy way to find that java.util.* is what i need to import, if i wanted to use the class ArrayList ?

View Replies View Related

Finding Median Of Array?

May 3, 2014

I'm trying to find the median of a set of numbers inputted into an array and I wanted to know how I would pass the array to the median calculator after I use selection sort to organize the numbers.THIS IS THE CODE THAT ORGANIZES THE ARRAY:

public void selectionSort(double[] myArray) {
for (int i = 0; i < myArray.length - 1; i++)
{
int index = i;
for (int j = i + 1; j < myArray.length; j++)

if (myArray[j] < myArray[index])

[code]....

The code that finds the median will only work if the array being used is already organized. How do I pass the new sorted array to the code that finds the median?

View Replies View Related

Finding The Frequency Of A Pitch

Apr 23, 2014

I'm looking for a library to do FFT stuff, or anything similar. I need to be able to judge the pitch of a note (played on a string instrument).

View Replies View Related

Finding Minimum Value Using Arrays?

Apr 22, 2015

I am writing a code based on the following question: "Write a method called arrayMin that accepts as an argument an array of numbers and returns the minimum value of the numbers in that array.Create an array to test your code with and call the method from main to print the min to the screen".

I cannot seem to get the code to calculate the minimum number.

Here is my progress thus far:

import java.util.*;
public class Lab11q3
{
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
int number;

[code]....

View Replies View Related

Programming About Finding Triangle

Nov 25, 2014

class triangle
{
public static void main (String[] args)
{
System.out.println("Provide three side lengths - 000 to terminate.");
int a = In.getInt();
int b = In.getInt();
int c = In.getInt();
 
[code]....

My problem is that when I enter 5,2,5 it should be isosceles and acute but it comes out as isosceles and obtuse, and when I type 5,5,5 it comes out equilateral and right. The only one that works is if I enter 3,5,4 it will come out as scalene and right. I been at this for a while and my math looks correct.

View Replies View Related

Finding A Cell On Edge

Jan 22, 2015

For my project I have to write a piece of code where it returns true or false value depending whether the indicated cell is on edge of a rectangular grid (true) or not (false). Any algorithm for the following method: public static boolean onEdge (int n, int numRows, int numCols)?? To highlight, numRows and numCols and n start from 0.

View Replies View Related

Finding Minimum Value Of Array

Sep 11, 2014

I'm almost finished with my assignment, I'm just having one small issue. The goal of this assignment is to have a user input as many values they want(up to 10) into a list. I need to store those in an array then figure out the sum of the numbers, the average, the Largest value, and the smallest value. I get everything to print out correct so far except for the Smallest number, it is returning a 0 every time. Here is my code:

import java.util.Scanner;
public class SimpleList{
Scanner in = new Scanner(System.in);
final private static int ARRAY_LENGTH = 10;
private float[] List = new float[ARRAY_LENGTH];
private int count = 0;

[Code] ......

View Replies View Related

Subset - Finding Smallest Possible Sum

Aug 2, 2014

I'm trying to apply a subset problem without using O(n^2) complexity. I need to find the smallest possible sum between 2 sets of 2 numbers in a lists so n1 + n2 = n3 + n4 = sum.

I have found solutions that all involve having the sum first and just finding the two pairs which involves using a hash table and then taking each number and subtracting it off the sum and looking for possible combinations.

How to do it if nothing but the list of numbers is given. So no sum and no hint of the pairs.

I put this in the Java section because I'm doing it in Java and there seems to be no generic algorithm/programming Topic area.

View Replies View Related

Finding Factorian - Sum Of All Factorials

Apr 10, 2014

I have written the following code to try and find a factorian but it doesn't work all the time. A factorian is supposed to be the sum of the factorials.

public static boolean isFactorion(int n){
boolean rv = false;
int sum =0;
int fact = 1;
for(int i = n;i>=1;i--){
fact = fact * i;

[Code] ......

View Replies View Related

Finding Binary Of Negative Numbers?

Mar 22, 2014

How do u find the binary of negative numbers? I already did it for positive numbers,?

View Replies View Related

Finding Palindromes From Stack And Queue?

Apr 30, 2015

I'm trying to create a class that takes an String from a Stack and checking if it's a palindrome than taking a another String from a queue and checking if that is also a palindrome.

import java.util.Stack;
public class Palindrome {
 public static void main(String[] args) {
// TODO Auto-generated method stub
 String enteredLine;
int leftStack, rightStack;
int leftQueue, rightQueue; 
PalinedromeArray stack1 = new PalinedromeArray();

[code]....

View Replies View Related

Java Errors Finding Symbol?

Apr 7, 2014

Here is my code that is supposed to read a user-selected document, create text boxes from that info, and display them. (There is a lot of code in there that may not be relevent, but just ignore that.) When I compile, I receive errors that it can not find the symbols color, xIn, yIn, w, and h.

Here's my code:

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
public class Ex22 extends Basic {

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Finding Strings In A JTable

Jan 31, 2015

I am having a problem finding string objects in a jTable. I use setValueAt() to write string variables into a jTable.

I can then use getValueAt() to search to find any of those strings. All works fine until I edit an entry in the table. Then I can never find that string again.

In fact, if I just click in the cell type a character, then delete that character, something changes. The contents of the cell look the same but the search for it doesn't find it.

For example if I have a string "xyz" that was written in a cell. If I set the search value, "a=xyz", and "b=getValueAt(some cell)".

Then at the compare:

if(a==b) I can hover over a and b and I see that;
a = (java.lang.String) xyz

and

b = (java.lang.String) xyz

[note I am using NetBeans to do this]

after the compare, the true path is taken .

If I then click in the cell then click out and try the same compare, everything is exactly the same including what gets reported when I hover. But the false path is taken at the "if".

View Replies View Related

Javac Not Finding Source Files

Apr 3, 2015

In using javac, I have installed the JDK, set the PATH and JAVA_HOME. When I run this:

"C:Program FilesJavajdk1.8.0_40injavac" -cp C:Gj_javacHTMLCarbonResults.java

I get: javac: no source files

Since I placed the source file path in the command line, I don't understand why it can't find the one .java file.

View Replies View Related

Finding Longest Zig-Zag Sequence In Array

Oct 26, 2014

From a given array of positive and negative numbers, I have to find the longest SUB-Array which represents a Zig-Zag sequence...

A Zig-Zag sequence means that one number is possitive, the next one negative, the next one possitive, and so on and so on...

Like this: -1, 4, -5, 6, -9, 2, -9 etc....

So that means, if the array looks like this:

1, 4, -2, -5, 6, -9, 1, -4, 9, -8, 7, 4, -3

the longest sub-array which fulfills the requirement is (the part in bold):

1, 4, -2, -5, 6, -9, 1, -4, 9, -8, 7, 4, -3

and I only need it's length, which in this case is: 8

View Replies View Related

Finding Average Of Multidimensional Array

Mar 2, 2015

public class StuTest {
private static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args){
int[][] testScores; // [students][tests]
String[] stuNames;

[Code] ....

The method I am having issues with is the "printStudentReport" method. I am trying to calculate the average of a randomly generated number of students and tests. For my "printTestReport" method, I have to calculate the average of the test by test number.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved