• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Can someone help me add methods into my code?

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I had to write a code to encrypt a password the user inputs which I was able to do. But now I have to add methods and make a driver class which I am terrible at. Whenever I try to the file with all the code can't pick up the variables I set in the driver class and it becomes a giant disaster. So can someone give me the basics on how to add a method and a driver class into a code? Every part of the code that has // has to be its own method. Here is the code I am trying to add methods into



Sorry for asking such an open ended question but I have no idea where to even begin.
 
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
still unable to understand your problem.. Can you please elaborate?
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I'm understanding correctly, you want to do something like this:
 
John Sing
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:If I'm understanding correctly, you want to do something like this:



Exactly but whenever I try something like that I get errors so I assumed I was doing it wrong. Here is the part of my new code with the method I tried to put in.



and here are the errors I get

[line: 11]
Error: illegal start of expression
[line: 11]
Error: ';' expected
[line: 11]
Error: ';' expected

So what should I do to fix these errors?
 
Marshal
Posts: 8661
623
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Sing wrote:So what should I do to fix these errors?

There are few things.

1st - you cannot declare method within method, so you have to close your main method, then declare another.
2nd - you cannot call non static method in static method.

This sort of example could help you only for a quick little practise programs. For better practises search for faq "Main Is A Pain".

Example to solve 1st and 2nd mentioned points.

 
Heroic work plunger man. Please allow me to introduce you to this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic