java - non-static method cannot be referenced from a static method -


I am trying to print my high rights object, but it does not leave me ... telling non- Static method can not be referenced from a static method I basically want to print all the values ​​by adding it ("AAA", "AACCA" .. etc).

  import java.util. *; Public Class Ex8 {Public Zero Printhargers (Array List & Lt; Securitates & gt; A) {For (Security Ratings M: A) {If (Highest Rights Of M) {System.out.println (HighRights.getName ()); }}} Public static zero main (string [] a) {ArrayList & lt; Safety Rights & gt; Ma = new arreelist & lt; Security & gt; (); Ma.add (new highlights ("AAA"); Ma.add (new highlights ("AACCCA")); Ma.add (new high ratings ("B")); Ma.add (new highlights ("AAAAA"); New Ex8 () PrintHighUsers (ma); }}   

High Rights Class:

  Public Class Highlights Raises Safety Rivies {Name of Private String; Public Highlights (String En) {Super (true); This.name = n; } Public string getName () {return name; } Public static zero main (string [] a) {high rights = new highlights ("Lisa"); System.out.print (s.getName () + "" + s.getSecret ()); }}   

Thanks.

in

  println (HighRights.getName ());   

You are trying to apply the getName () status, but this is not a static method.

What do you want

  System.out.println ((High RIGHT) m) .getName ());   

In other words, you need to enter your references for high rights so that getName () method is accessible and Rather than reference, context can be applied.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -