Implementation Of Stack Methods In Java

Jun 3, 2014

I have to implement all the stack methods in java such as push, pop empty, not using the ready methods but have to create them and to execute an exercise but is sth wrong with it

public class Stiva {
/** the problem is here how to declare the stack 1 and stack 2 and kreu(head) gjmax(size)*/
int Gjmax;
int array[] = new int[Gjmax];
int kreu;
private Stiva stiva1;
private Stiva stiva2;

[Code] .....

View Replies


ADVERTISEMENT

Implementation Of All Stack Methods In Java

Jun 3, 2014

I have to implement all the stack methods in java such as push, pop empty, not using the ready methods but have to create them and to execute an exercise but something wrong with it....

public class Stiva {
/** the problem is here how to declare the stack 1 and stack 2 and kreu(head) gjmax(size)*/
int Gjmax;
int array[] = new int[Gjmax];
int kreu;
private Stiva stiva1;
private Stiva stiva2;

[Code] .....

View Replies View Related

Implementation Of Stack Methods - Declaration Of Stack1 And Stack2

Jun 3, 2014

I have to implement all the stack methods in java such as push, pop empty, not using the ready methods but have to create them and to execute an exercise but is sth wrong with it

public class Stiva {

/** the problem is here how to declare the stack 1 and stack 2 and kreu(head) gjmax(size)*/

int Gjmax;
int array[] = new int[Gjmax];
int kreu;
private Stiva stiva1;
private Stiva stiva2;

[Code] .....

View Replies View Related

Array Based Implementation Of A Stack - Generic Array Creation

Oct 10, 2014

So I have this stack. I'm writing out all the operations and what not but I'm having trouble bypassing this "generic array creation" problem. I'm meant to be creating an array based implementation of a stack and from my research from google and my various attempts at things, I have not found a solution that works.

In addition; I have all the operations written that I need except for one final one. And that is clear(). clear() is meant to empty the array, essentially it is a popAll() method. Then all I need to do is set up so I can print out the arrays and I should be able to handle everything else.

StackInterface:

/**
An interface for the ADT stack.
*/
public interface StackInterface<T>
{
/** Adds a new entry to the top of this stack.
@param newEntry an object to be added to the stack */
public void push(T newEntry);

/** Removes and returns this stackÕs top entry.
@return either the object at the top of the stack or, if the stack is empty before the operation, null
*/
public T pop();

[Code] ....

View Replies View Related

FFT Convolution Implementation In Java

Dec 26, 2014

Not necessarily Java related, more a general programming issue I have come a long and I am currently using java to mock up a project that will eventually get moved over to C++.

I am trying to implement FFT Convolution into a java project and have things partially working, I do not know if it is a coding issue, logic issue or if I simply know nothing of FFT and convolution.

For starters I got an FFT library that I do have working, if I create a small array pass it into the forward FFT, do a little bit of bit manipulation (converting a complex array of size n*2 into a re[] and im[] of size n), run the inverse FFT and do the same bit manipulation again I get back where I started.

However if I take two arrays, a Dirac Delta function (an array with a 1 followed by zeros for the rest of the array) and a stepping kernel (ex. {1, 2, 3, 4 etc}), I would expect to get the forward FFT of both arrays, bit manipulation, multiply them together, Inverse FFT, and bit manipulate again and the result would be the kernel. I have not had such luck.

This is the gist of the program:

// bit manipulation, converts complex array to two re and im arrays
public void bitTwiddle(double [] real, double [] real2, double [] imaginary){

double [] realCopy = new double [] {0, 0, 0, 0, 0, 0, 0, 0};
double [] imaginaryCopy = new double [] {0, 0, 0, 0, 0, 0, 0, 0};

for (int idx = 0; idx < (N * 2); idx++){
realCopy[idx] = real [idx];

[Code] ....

This is the result:

Quote
=====================================================================
Dirac Delta In Time Domain:
Real:1.000.000.000.00
Imag:0.000.000.000.00
=====================================================================
Dirac Delta Frequency Domain
Real:0.500.500.500.50
Imag:0.000.000.000.00
=====================================================================
Kernel In Time Domain
Real:1.002.003.004.00
Imag:0.000.000.000.00
=====================================================================
Kernel In Frequency Domain
Real:5.00-1.00-1.00-1.00
Imag:0.00-1.000.001.00
=====================================================================
Result: Dirac Delta x Kernel
Real:2.50-0.50-0.50-0.50
Imag:0.00-0.000.000.00
=====================================================================
Result In Time Domain
Real:0.501.501.501.50
Imag:0.000.000.00-0.00

View Replies View Related

Why Class Implementation Is Not Possible In Java

May 14, 2014

Why Class implementation is not possible in java....

View Replies View Related

Decision Table Implementation In Java?

Jan 8, 2015

how to start with decision table implementation in java

View Replies View Related

Implementation Of Login Page With Java

Mar 25, 2014

Code for login page by java and how we can implement it.

View Replies View Related

Non Local Means Filter Implementation In Java?

Feb 23, 2014

How to implement non local means filter in java?

View Replies View Related

JavaFX :: Implementation Of Web Data Into Non-web Java Application

Aug 4, 2014

What would be the most effective method to display data grabbed from a web source that is queried every second, for example the most recent EUR/USD price?

I already have access to the data stream, and I've built a simple FXML in javaFX that contains a grid; I'm not sure how to approach putting the live ticking data into the grid so it continues to update as the price changes, for example.

View Replies View Related

Java Computing Height Of Stack

Jun 2, 2015

Compute the height of a stack. Then determine whether that value is found in the stack element .

View Replies View Related

Finding Class In Java For Implementation Of Graph Theory?

Nov 15, 2014

I want to use graphs in java. Is there any class in java for implementation of graph theory? I most create a graph and run DFS(Depth First Search) algorithm on that.

View Replies View Related

2048 Game Implementation In Java - Rectangle In GameBox

Apr 4, 2014

I want to implement the 2048 game in Java.

I made the game logics, but now I need to implement the interface.

I made 2 classes GameBox and ContainerBox that extends JComponent.

I painted in GameBox a rectangle and now I want to initialize a matrics of GameBoxes in ContainerBox so I used:

GameBox GB[][] = new GameBox[4][4];

I am thinking about drawing the Boxes in something like this:

for(int i=0;i<4;i++)

for(int j=0;j<4;j++)

but I don't know how to draw those rectangles in the for...

View Replies View Related

Java Calculator Using Stack Data Structure

May 21, 2014

My assignment is to design a simple GUI calculator using the stack data structure to perform additions, subtractions, multiplications and divisions. But i having error while i press the action there.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.util.Stack;
public class JCalculator implements ActionListener {

[Code] ...

View Replies View Related

Java QuickSort Stack Overflow Error

Jan 19, 2014

I have an error using quicksort and this is a project ... The error occurs for numbers such as 7500 and bigger ...

Exception in thread "main" java.lang.StackOverflowError
at QuickSort.QuickSort(QuickSort.java:45)
at QuickSort.QuickSort(QuickSort.java:46)
at QuickSort.QuickSort(QuickSort.java:46) ...

Java Code:

import javax.swing.JOptionPane;
public class QuickSort{
public static void main(String[] args){
int p=new Integer(JOptionPane.showInputDialog("Jepni numrin e kufizave: "));
int[] ListaNumrave= new int[p];
//QuickSort Zbrites

[Code] .....

View Replies View Related

Palindrome Program - Java Stack And Queues

Aug 13, 2014

I am trying to figure out stacks and queues and was trying to get this Palindrome program working so I could then play with it and use the Java visualizer site but for some reason the program isn't working correctly. It always states that the input is a palindrome no matter what the user input is.

The book that I got the code from is a little old so I changed a couple small things that I thought needed updating like adding scanner. I wanna use one with a custom array based stack and queue class rather than the java.util.Stack and Queue interface, just for understanding stacks and queues better hopefully.

import java.util.Scanner;
import javax.imageio.IIOException;
public class PalTest {
public static void main(String[]args) throws IIOException
{
Scanner scan = new Scanner(System.in);
PalindromeTesting x = new PalindromeTesting();

[Code] .....

View Replies View Related

How To Call Java Methods From Different Java File

Apr 14, 2015

I create 2 files:

CircleCalculationMethod.javaMain.java 

In Main.java, How can i call method in CircleCalculationMethod.java ?

Should I put everything in same folder ??Should i do something like "import CircleCalculationMethod.java"Should i do something like create a package ...

I use Eclipse software

View Replies View Related

Why Can't Java Run Two Methods

Feb 14, 2015

I'm new to Java, and I just created this script:

public class HelloWorld {
public static void main(String[] args) {
String firstLine;
String startUp;
int hour, minute;

[code]...

Every time I try to run this is eclipse, I only get the first part, so it reads in the console: "Hello, world. The time is now 9:15. I'm tired."I want it to read: "Hello, world. The time is now 9:15. I'm tired. (new line) Today is Wednesday."

View Replies View Related

Java Methods And Percentages

Aug 6, 2014

I have a 'small' question:I am trying to create a method that will deduct the same percentage for a number of times, example:

a + b = c
c - 3% = d
d - 3% = e
e - 3% = f......

and so on and so forth, for a number specified earlier in the program, until I get to my final result.

View Replies View Related

Static Methods In Java Interfaces?

Jun 16, 2010

Why can't we have static methods in an interface?

View Replies View Related

Java - How To Make Array Of Methods

Aug 6, 2014

How to build an array that calls methods if i understand it correctly .... if this is possible a simple example of this.

View Replies View Related

Java Programming Project Involving Get And Set Methods?

Apr 4, 2014

1. Modify the following class so that the two instance variables are private, there is a constructor that accepts both the player's name and sport and there are get and a set methods for each instance variable:

public class Player {
String name;
String sport;
}

2. You can pass an instance of this class to the JLabel constructor if you want to display text in the label.Select one:
a. myLabel
b. myText
c. String
d. JTextField
e. JLabelText

how to start making this work?cause i am not familiar with the terms here and want to complete this program and I am new to java programming?

View Replies View Related

Java Classes - Trace Methods Calls

Apr 1, 2015

Consider the two simple Java classes below:

Java Code:

class Computer {
Computer() {
System.out.println("Constructor of Computer class.");
}
void On() {
System.out.println("PC turning on...");
}
void working() {

[Code] ....

After the program run, how do I trace (1) which object call which method (2) and how many times?

View Replies View Related

Implement HashMap Put And Get Methods Without Using Java Collection Framework?

Feb 11, 2014

How to implement HashMap put and get methods without using Java Collection framework?

View Replies View Related

Does JavaFX Methods And Objects Works Into Java Application

Nov 22, 2014

I was doing a project in a usual Java Application, but now maybe I have to use some tools that are contained in javafx.scene.media.MediaPlayer so I wonder if can it all work? Will javafx methods and such works?

I have to use javafx.scene.media.MediaPlayer beacuse I have to create a very simple audio player (one jbutton and one jcombobox).

View Replies View Related

Java Swing Frame Can't Call On Other Methods From Main

Mar 25, 2015

I am trying to make a 2d graphical animation using the java swing classes in order to make a frame. I had a basic version working when all of the code was under the main method, but when I moved some into another method it broke it. With y understanding of java my code should work as I create a variable of the method containing the code and then assign the size and exit button. However this causes many problems such as my BeaconFrame method informing me that it is unused when I have used it. Here is my code:

import javax.swing.*;
import java.awt.*;
 public class BelishaBeacon {
  public void BeaconFrame() {
JFrame frame = new JFrame();
JPanel panel1 = new JPanel();

[code]....

View Replies View Related







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